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

--- Comment #36 from James Y Knight <foom at fuhm dot net> ---
(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).

Reply via email to