This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-10-11
(From submission #755.)
Subclause 11.5.2 [class.union.anon] paragraph 1 specifies:
... Each member-declaration in the member-specification of an anonymous union shall either define one or more public non-static data members or be a static_assert-declaration. Nested types, anonymous unions, and functions shall not be declared within an anonymous union. ...
This rule yields:
struct A { union {int x;;} u; }; // OK
struct B { union {int y;;}; }; // error
Both class definitions ought to be allowed. There is implementation divergence: MSVC, gcc, and EDG accept both class definition; clang accepts both in default mode and rejects both in pedantic mode (rejecting empty declarations in all class definitions).
Suggested resolution:
Change in 11.5.2 [class.union.anon] paragraph 1 as follows:
... Each member-declaration in the member-specification of an anonymous union shalleitherdefine one or more public non-static data members, be an empty-declaration, or be a static_assert-declaration. Nested types, anonymous unions, and functions shall not be declared within an anonymous union. ...