This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110c. See for the official list.


2080. Example with empty anonymous union member

Section: 11.5  [class.union]     Status: CD5     Submitter: John Spicer     Date: 2015-02-03

The example in 11.5 [class.union] paragraph 8 reads,

  union U {
    int x = 0;
    union { };
    union {
      int z;
      int y = 1; // error: initialization for second variant member of U

The empty anonymous union appears to be a violation of the requirement in 11.4 [class.mem] paragraph 1,

Except when used to declare friends (11.8.4 [class.friend]), to declare an unnamed bit-field (11.4.10 [class.bit]), or to introduce the name of a member of a base class into a derived class (9.9 [namespace.udecl]), or when the declaration is an empty-declaration, member-declarations declare members of the class, and each such member-declaration shall declare at least one member name of the class.

Additional note, February, 2021:

The issue was resolved editorially.