https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64644
Bug ID: 64644 Summary: "warning: anonymous union with no members" should be an error with -pedantic-errors Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: harald at gigawatt dot nl Compiling static union { }; with gcc -std=c++11 -pedantic-errors gives test.cc:1:16: warning: anonymous union with no members static union { }; ^ It's fine that it's a warning by default, but I think it should be an error with -pedantic-errors, because it violates the last part of [dcl.dcl]p3: when the init-declarator-list is omitted, "the decl-specifier-seq shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration." No exception is made for anonymous unions, so the only way an anonymous union can avoid violating this is by having members. (FWIW, I cannot find any options to get any warning whatsoever with clang, Intel or Sun, and MSVC only warns at the highest warning level, regardless of whether language extensions are enabled. As far as I can tell, GCC's current handling is already the best of these five.)