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

2024-11-11


1317. Unnamed scoped enumerations

Section: 9.7.1  [dcl.enum]     Status: NAD     Submitter: John Spicer     Date: 2011-05-12

The text of 9.7.1 [dcl.enum] paragraph 2 explicitly forbids unnamed scoped enumerations:

The optional identifier shall not be omitted in the declaration of a scoped enumeration.

There does not appear to be a good rationale for this restriction since a typedef name can be used to name the enumerators. It is also inconsistent with similar constructs. For example,

    typedef enum class { e } E;
    E x = E::e;

is ill-formed, but

    typedef struct { enum { s }; } S;
    int y = S::s;

is well-formed.

Rationale (August, 2011):

The use of typedef names for linkage purposes is intended for C compatibility and should not be extended to features that are not part of the C subset of C++.