Title
Duplicate declarations of enumerations in class scope
Status
open
Section
11.4.1 [class.mem.general]
Submitter
Richard Smith

Created on 2024-12-31.00:00:00 last changed 3 weeks ago

Messages

Date: 2024-12-31.00:00:00

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]

History
Date User Action Args
2024-12-31 00:00:00admincreate