[Bug middle-end/101836] __builtin_object_size(P->M, 1) where M is an array and the last member of a struct fails

kees at outflux dot net gcc-bugzilla@gcc.gnu.org
Tue Jun 14 00:00:31 GMT 2022


--- Comment #21 from Kees Cook <kees at outflux dot net> ---
(In reply to Martin Sebor from comment #20)
> Well, I just "asked" for such an option the same way you asked for
> -fstrict-flex-arrays in comment #3, because I believe it would be useful to
> make the BOS improvements you're looking for available even to code that
> can't do a whole-hog replacement of all trailing arrays with flexible array

Right, sorry, I meant, "I have a project waiting to use this feature right
now", where as other projects might, upon discovering this feature, decide they
also only need "-fstrict-flex-arrays". e.g. what option would GCC itself use?

> members.  The spelling of the option names doesn't seem important to me
> (they could be separate options, or the same one with an argument).

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.

More information about the Gcc-bugs mailing list