https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836

Bill Wendling <isanbard at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |isanbard at gmail dot com

--- Comment #40 from Bill Wendling <isanbard at gmail dot com> ---
(In reply to James Y Knight from comment #36)
> (In reply to Kees Cook from comment #34)
> > > Great. Adding that flag, and eliminating the -fstrict-flex-arrays=3 option
> > > from this proposal would be good.
> > 
> > Hmm? No, -fstrict-flex-arrays=3 is still needed (because it changes compiler
> > _behavior_, e.g. for proper FORTIFY coverage or trailing arrays, etc).
> 
> There is no purpose served by writing a struct member `int x[0];` other than
> to create a FAM. Zero-length arrays are not permitted by the C standard, but
> are a GCC compiler extension explicitly for the purpose of creating a FAM.
> This is entirely unlike `int x[1];` or `int x[10];` which of course have a
> primary meaning as a concrete array size...
> 
> If the linux kernel doesn't want to allow `int x[0];` FAMs, then prohibit
> them entirely using -Werror=zero-length-array (once it's implemented).

[Kees, correct me if I'm wrong.]

I don't think this satisfies what Kees initially asked for. The GCC extension
that a trailing `[0]' array in a structure is causing FORTIFY to fail. It would
be great to remove them all, but that's more-or-less a separate issue from
making FORTIFY work in all instances. (From what I understand, removing the
trailing `[0]' from Linux is an ongoing project.)

The question then is if `-fstrict-flex-arrays=3' is used, what does a `[0]' at
the end of a struct represent (assuming GCC no longer treats it as an FAM)?

Reply via email to