CWG Issue 2621 (original) (raw)

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

2025-04-13


2621. Kind of lookup for using enum declarations

Section: 9.8.2 [enum.udecl]Status: C++23Submitter: Sean BaxterDate: 2022-08-17

P2720R0 comment CA 054

[Accepted as a DR at the November, 2022 meeting.]

Consider:

enum class E { a, b, c };

using MyE = E;

int main() { using enum MyE; // #1 }

Does the lookup for the elaborated-enum-specifier at #1 use type-only lookup per 6.5.6 [basic.lookup.elab]? There is implementation divergence; EDG, gcc, and MSVC accept, clang rejects.

Suggested resolution [SUPERSEDED]:

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

Lookup for the elaborated-enum-specifier is as specified in 6.5.6 [basic.lookup.elab].The elaborated-enum-specifier shall not name a dependent type and the type shall have a reachable enum-specifier.

CWG telecon 2022-09-09:

The example at #1 is intended to be valid; even though the grammar suggests that an elaborated-type-specifier is used here, an ordinary (not a type-only) lookup is performed.

Proposed resolution (approved by CWG 2022-09-23) [SUPERSEDED]:

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

The terminal name of the _elaborated-enum-specifier_undergoes ordinary lookup (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]).The elaborated-enum-specifier shall not name a dependent type and the type shall have a reachable enum-specifier.

CWG 2022-11-07:

Use the wording approach presented in CA-054, with necessary adjunct fixes.

Proposed resolution (approved by CWG 2022-11-10):

Change the grammar before 9.2.9.5 [dcl.type.elab] paragraph 1 as follows, merging the grammar productions:

elaborated-type-specifier : class-key attribute-specifier-seqopt nested-name-specifieropt identifier class-key simple-template-id class-key nested-name-specifier templateopt simple-template-id elaborated-enum-specifier

elaborated-enum-specifier : enum nested-name-specifieropt identifier

Change the grammar before 9.8.2 [enum.udecl] paragraph 1 as follows:

using-enum-declaration: using elaborated-enum-specifier enum using-enum-declarator ;

using-enum-declarator: nested-name-specifieropt identifier nested-name-specifieropt simple-template-id

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

A using-enum-declarator names the set of declarations found by lookup (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator.The elaborated-enum-specifier using-enum-declarator shallnot name a dependent designate a non-dependenttype and the type shall have with a reachable enum-specifier.