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

--- Comment #22 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> ---
(In reply to Kees Cook from comment #21)
> How about "-fnot-flex-arrays=N" to mean "trailing arrays with N or more
> elements will NOT be treated like a flex array"?
> 
> Then code with sockaddr can use "-fnot-flex-arrays=15", code with "[1]"
> arrays can use "-fnot-flex-arrays=2", code with only "[0]" arrays can use
> "-fnot-flex-arrays=1", and "-fstrict-flex-arrays" can be an alias for
> "-fnot-flex-arrays=0", which Linux would use.

An arbitrary N will only make it abuse-friendly and potentially mask bugs.  IMO
if we choose to make multiple levels here it should only be
-fstrict-flex-arrays={1,2} where 1 (the default) only allows "[]" and 2 allows
"[0]", disabling all other size values.  For anything else,
-fno-strict-flex-arrays.  My opinion on the default is not strong FWIW.

Reply via email to