This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-31


2979. Duplicate declarations of enumerations in class scope

Section: 11.4.1  [class.mem.general]     Status: open     Submitter: Richard Smith     Date: 2024-12-31

Consider:

  struct S {
    enum B {
      A
    };
    using B::A;
    // or:
    // using enum B ;
  };

This is neither prohibited by 11.4.1 [class.mem.general] paragraph 6 (because using-declarators are not members per 11.4.1 [class.mem.general] paragraph 3) nor by 9.9 [namespace.udecl] paragraph 8.

Possible resolution:

  1. Change in 9.9 [namespace.udecl] paragraph 8 as follows:

    [ Note: If a declaration is named by two using-declarators that inhabit the same class scope, the program is ill-formed (11.4.1 [class.mem.general]). [Example: ... -- end example ] -- end note ]
  2. Change in 11.4.1 [class.mem.general] paragraph 6 as follows:

    A member An entity shall not be declared or named by a using-declarator (9.9 [namespace.udecl]) twice in the member-specification, except that
    • a nested class or member class template can be declared and then later defined, and
    • an enumeration can be introduced with an opaque-enum-declaration and later redeclared with an enum-specifier.
    [ Example:
      struct S {
        class C;
        class C {};      // OK
        enum E { e };
        using E::e;      // error: redeclaration of e
      };
    
    
    -- end example ]

    [Note 4: A single name can denote several member functions provided their types are sufficiently different (6.4.1 [basic.scope.scope]). -- end note]