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

--- Comment #8 from qinzhao at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #3)
> This is intentional, if you embed an aggregate with flex array into another
> struct and ask not to cross the field boundaries (i.e. bos1), then the size
> of that field is exactly what is the maximum size.

As we discussed in PR 107952
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107952):

GCC extension accepts the following two cases:

**Case 1:

struct A { char data[1]; };
struct B { int n; struct A a; };

as if the a.data[] array is a flex-array.  

**Case 2: 

struct C { int n; struct A a; int x; };

as if a.data[] can be up to 4 elements. 

So, what's you mean by "not to cross the field boundaries" is for the above
Case 2? 
For Case 1, we should treat A.data as flexible array, and then B.A as a
structure that has flexible array, therefore B.A's size is flexible too. 

Is my understanding correct?

Reply via email to