https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107952
--- Comment #10 from Qing Zhao <qing.zhao at oracle dot com> --- > --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- > > GCC handles for example > > struct A { char data[1]; }; > struct B { int n; struct A a; }; > > as if the a.data[] array is a flex-array. Okay. Then the maximum size of __builtin_object_size for it should be -1, right? > It also handles > > struct C { int n; struct A a; int x; }; > > as if a.data[] can be up to 4 elements large (we allow an array to extend > flexibly to padding - but only if it is trailing). A little confused here: when the structure with a trailing flexible-array member is a middle field of an outer structure, GCC extension will treat it as a flexible-array too? But the maximum size of this flexible-array will be bounded by the size of the padding of that field? Is the above understanding correct? > I see that's not > consistently handled though. > > I think the [] syntax should follow the C standard as what testcases are > accepted/rejected by the frontend and any extensions there should be > documented Agreed, usually where these extension should be documented? > (those are separate from what the former array_at_struct_end_p > allowed semantically So, your mean to leave such extension out of “array_at_struct_end_p” (the current “array_ref_flexible_size_p”)? Handle them separately instead?