https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94132
Bug ID: 94132 Summary: Valid usage of flexible array member failing to compile Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: amir.ahmed.ansari at outlook dot com Target Milestone: --- Until gcc 9.2.0, the following usage was correct: struct S { int size; int data[]; }; struct { S s; int data[16]; } var; >From 9.2.1 onwards, this no longer compiles because the checking has gotten stricter: <source>:3:9: error: flexible array member 'S::data' not at end of 'struct<unnamed>' 3 | int data[]; | ^~~~ <source>:8:9: note: next member 'int <unnamed struct>::data [16]' declared here 8 | int data[16]; Funnily, the following workaround circumvents the check: struct { union { struct { S s; int data[16]; }; }; } var; Can we make this check more robust so valid usage isn't rejected? I will leave it up to the experts to find the solution, but it would be easy for me to use an attribute such as [[space_follows]] to tell the compiler that valid space follows this member.