[Bug c/54162] Does not accept static global anonymous unions or structs
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Thu Aug 2 23:23:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54162
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-08-02 23:23:19 UTC ---
On Thu, 2 Aug 2012, josh at joshtriplett dot org wrote:
> C1X, and numerous other compilers, support static anonymous unions or structs
> at file scope. For example, the following code should work with a C1X
> compiler:
No it shouldn't. Anonymous structures and unions are *members* of a
containing structure or union, not declarations outside such a context;
see C11 6.7.2.1 paragraph 13. The constraint in 6.7 paragraph 2 applies:
"A declaration other than a static_assert declaration shall declare at
least a declarator (other than the parameters of a function or the members
of a structure or union), a tag, or the members of an enumeration.". Your
union declares none of those.
More information about the Gcc-bugs
mailing list