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

--- Comment #19 from Kees Cook <kees at outflux dot net> ---
(In reply to Martin Sebor from comment #18)
> The zero size case exists (and is documented) solely as a substitute for
> flexible array members.  Treating is as an ordinary array would disable that
> extension.  It might be appropriate to provide a separate option to control
> it but conflating it with the other cases (one or more elements) doesn't
> seem like the robust design.
> 
> As I mentioned in the review of the Clang change,
> https://reviews.llvm.org/D126864, so that code bases that use some larger
> number of elements than zero, such as one, and that can't easily change, can
> still benefit from the BOS enhancement for the remaining cases, it would be
> helpful for the new option to accept the minimum number of elements at which
> a trailing array ceases to be considered a poor-man's flexible array member.

I see your point about gaining the "trailing array" fix without breaking the
older code bases, but that doesn't seem to fit the name (nor purpose) of
-fstrict-flex-arrays, which should be considered a "complete" fix.

To me it looks like -fstrict-flex-arrays should kill the [0] extension, the
ancient [1] misuse, and the "anything trailing is flex" logic. If fixing _only_
the latter is desired, perhaps add an option for that, but no one is actually
asking for it yet. :) The Linux kernel wants the "fully correct" mode.

Reply via email to