SDCC is right there, and gcc-4.6.2 does not compile it "just fine" either. Well, if you ask it to adhere to the standard pedantically.
Compiling with -std=c99 -pedantic
(or -std=c1x -pedantic
), gcc emits
warning: invalid use of structure with flexible array member
and clang-3.0 behaves similarly, its warning is slightly more informative:
warning: 'STRLIST_ENTRY' may not be used as an array element due to flexible array member
The standard prohibits that in 6.7.2.1 (3):
A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of a structure with more than one named member may have incomplete array type; such a structure (and any union containing, possibly recursively, a member that is such a structure) shall not be a member of a structure or an element of an array.
(emphasis is mine)
gcc and clang allow having struct
s with flexible array members as members of struct
s or arrays as an extension. The standard prohibits that, so code using that is not portable, and every compiler is within its rights to reject the code.
The linked issue is not relevant, it is about not giving a warning if a struct
with a flexible array member is instantiated as an automatic, which isn't allowed per the standard (but accepted by SDCC and others as an extension).