[Bug middle-end/108036] [11/12/13/14 Regression] Spurious warning for zero-sized array parameters to a function

2024-03-07 Thread alx at kernel dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036

--- Comment #9 from Alejandro Colomar  ---
Hi Lundin!

On Thu, Mar 07, 2024 at 10:18:12AM +, daniel.lundin.mail at gmail dot com
wrote:
> --- Comment #8 from Daniel Lundin  ---
> I don't believe char past_end[0] is valid C, because it is an invalid array
> declaration. Unlike [] or [*] that declares an array of incomplete type. 
> 
> Since it is a function parameter, it will of course later get adjusted to a
> pointer to the first element. But it still has to be a valid declaration to
> begin with. Similarly, char arr[][] is invalid because it remains an 
> incomplete
> type after adjustment (see C17 6.7.6.4 §4).

Agree; ISO C seems to not allow this with their wording.  (I wish it did,
because it's just a matter of wording, not that they don't allow passing
a pointer to past the end).  But maybe the wording needed for allowing
this would have other undersirable consequences, so I'm happy as long as
GNU C would support this.

> gcc does allow [0] as an extension since that was commonly used for purposes 
> of
> implementing the "struct hack" back in the days before flexible array members
> were standardized.
> 
> The conclusion ought to be that gcc should let [0] through if compiled in
> -std=gnu23 mode but not in -std=c23 and/or -pedantic.

And agree; if support for this is added, pedantic or ISO C modes should
complain about it.

Have a lovely day!
Alex

[Bug middle-end/108036] [11/12/13/14 Regression] Spurious warning for zero-sized array parameters to a function

2024-03-07 Thread daniel.lundin.mail at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036

Daniel Lundin  changed:

   What|Removed |Added

 CC||daniel.lundin.mail at gmail 
dot co
   ||m

--- Comment #8 from Daniel Lundin  ---
I don't believe char past_end[0] is valid C, because it is an invalid array
declaration. Unlike [] or [*] that declares an array of incomplete type. 

Since it is a function parameter, it will of course later get adjusted to a
pointer to the first element. But it still has to be a valid declaration to
begin with. Similarly, char arr[][] is invalid because it remains an incomplete
type after adjustment (see C17 6.7.6.4 §4).

gcc does allow [0] as an extension since that was commonly used for purposes of
implementing the "struct hack" back in the days before flexible array members
were standardized.

The conclusion ought to be that gcc should let [0] through if compiled in
-std=gnu23 mode but not in -std=c23 and/or -pedantic.

[Bug middle-end/108036] [11/12/13/14 Regression] Spurious warning for zero-sized array parameters to a function

2023-05-29 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|11.4|11.5

--- Comment #7 from Jakub Jelinek  ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.