Re: [PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Alejandro Colomar
Hi Martin, On Thu, Aug 14, 2025 at 02:21:10PM +0200, Martin Uecker wrote: > > > You could also add a warning when _Countof is applied to a > > > non-constant pointer. > > > > Yup, I should add that. I wouldn't enable it in any groups flags, > > though. I don't want people to start writing [cons

Re: [PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Martin Uecker
Am Donnerstag, dem 14.08.2025 um 14:05 +0200 schrieb Alejandro Colomar: > Hi Martin, > > On Thu, Aug 14, 2025 at 01:37:55PM +0200, Martin Uecker wrote: > > Am Donnerstag, dem 14.08.2025 um 12:19 +0200 schrieb Alejandro Colomar: > > > Hi Martin, > > > > > > On Thu, Aug 14, 2025 at 11:01:05AM +0200

Re: [PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Alejandro Colomar
Hi Martin, On Thu, Aug 14, 2025 at 01:37:55PM +0200, Martin Uecker wrote: > Am Donnerstag, dem 14.08.2025 um 12:19 +0200 schrieb Alejandro Colomar: > > Hi Martin, > > > > On Thu, Aug 14, 2025 at 11:01:05AM +0200, Alejandro Colomar wrote: > > > +void > > > +decay_obvious (int a[2]) > > > +{ > > >

Re: [PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Martin Uecker
Am Donnerstag, dem 14.08.2025 um 12:19 +0200 schrieb Alejandro Colomar: > Hi Martin, > > On Thu, Aug 14, 2025 at 11:01:05AM +0200, Alejandro Colomar wrote: > > +void > > +decay_obvious (int a[2]) > > +{ > > + _Countof (typeof (a)); /* { dg-error "invalid" } */ > > + _Countof (a + 1); /* { dg-e

Re: [PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Alejandro Colomar
Hi Martin, On Thu, Aug 14, 2025 at 11:01:05AM +0200, Alejandro Colomar wrote: > +void > +decay_obvious (int a[2]) > +{ > + _Countof (typeof (a)); /* { dg-error "invalid" } */ > + _Countof (a + 1); /* { dg-error "invalid" } */ It didn't occur to me the following test: alx@devuan:~/tmp

[PATCH v1 1/1] c: Add support for array parameters in _Countof

2025-08-14 Thread Alejandro Colomar
From: Martin Uecker As a GNU extension. I'll propose it for standardization, but first we'd need to make array parameters meaningful in the standard. This extension will allow using _Countof() in more places, reducing the chances of specifying an incorrect size accidentally. Due to how the arr