https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53548
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The second example is rejected (with a slightly different error) because C specifies that: As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member. I.e., flexible array members may be defined only in structures, not in unions. Accepting such code would be an extension to the language (which might be what you are proposing). But since an equivalent extension already exists (zero-size array), I'm not sure what the value of adding another would be. I tried to see if there was a way to use a flexible array member to achieve the effect you're looking for. Here's what I came up with (it causes -Wpedantic warnings, but so does the first accepted example): $ cat z.cpp && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -S -o/dev/null -xc z.cpp struct { short op; union { int i; char foo[0]; }; }; struct { short op; union { int i; struct { struct { } s; char foo[]; }; }; }; z.cpp:5:14: warning: ISO C forbids zero-size array ‘foo’ [-Wpedantic] char foo[0]; ^~~ z.cpp:7:1: warning: unnamed struct/union that defines no instances }; ^ z.cpp:14:13: warning: struct has no members [-Wpedantic] struct { } s; ^~~~~~ z.cpp:17:5: warning: invalid use of structure with flexible array member [-Wpedantic] }; ^ z.cpp:18:1: warning: unnamed struct/union that defines no instances }; ^