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

qinzhao at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 14 15:00:09 GMT 2022


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

--- Comment #25 from qinzhao at gcc dot gnu.org ---
So, based on all the discussion so far, how about the following:

** add the following gcc option:

-fstrict-flex-arrays=[0|1|2|3]

when -fstrict-flex-arrays=0:
treat all trailing arrays as flexible arrays. the default behavior;

when -fstrict-flex-arrays=1:
Only treating [], [0], and [1] as flexible array;

when -fstrict-flex-arrays=2:
Only treating [] and [0] as flexible array;

when -fstrict-flex-arrays=3:
Only treating [] as flexible array; The strictest level. 

any comments?


More information about the Gcc-bugs mailing list