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

2024-08-20


2877. Type-only lookup for using-enum-declarator

Section: 9.7.2  [enum.udecl]     Status: DR     Submitter: Richard Smith     Date: 2024-04-07

[Accepted as a DR at the June, 2024 meeting.]

Issue 2621 claimed to ask the question whether lookup for using enum declarations was supposed to be type-only, but the example actually highlighted the difference between elaborated-type-specifier lookup (where finding nothing but typedef names is ill-formed) and ordinary lookup.

However, consider:

  enum A {
    x, y
  };
  void f() {
    int A;
    using enum A;      // #1, error: names non-type int A
    using T = enum A;  // #2, OK, names ::A
  }

The two situations should both be type-only lookups for consistency, although #2 would not find typedefs.

Proposed resolution (reviewed by CWG 2024-05-17) [SUPERSEDED]:

Change in 9.7.2 [enum.udecl] paragraph 1 as follows:

A using-enum-declarator names the set of declarations found by type-only lookup (6.5.1 [basic.lookup.general] 6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]). The using-enum-declarator shall designate a non-dependent type with a reachable enum-specifier.

Additional notes (May, 2024)

An example is desirable. Also, the treatment of the following example is unclear:

  template<class T> using AA = T;
  enum AA<E> e; // ill-formed elaborated-type-specifier
  using enum AA<E>; // Clang and MSVC reject, GCC and EDG accept

Proposed resolution (approved by CWG 2024-06-26):

Change in 9.7.2 [enum.udecl] paragraph 1 as follows:

A using-enum-declarator names the set of declarations found by type-only lookup (6.5.1 [basic.lookup.general] 6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]). The using-enum-declarator shall designate a non-dependent type with a reachable enum-specifier. [ Example:
enum E { x };
void f() {
  int E;
  using enum E;   // OK
}
using F = E;
using enum F;     // OK
template<class T> using EE = T;
void g() {
  using enum EE<E>;  // OK
}
-- end example ]