<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 660</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="660"></A><H4>660.
  
Unnamed scoped enumerations
</H4>
<B>Section: </B>9.8.1&#160; [<A href="https://wg21.link/dcl.enum">dcl.enum</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>15 November 2007<BR>


<P>[Voted into the WP at the September, 2008 meeting.]</P>

<P>The current specification of scoped enumerations does not appear
to forbid an example like the following, even though the enumerator
<TT>e</TT> cannot be used:</P>

<PRE>
    enum class { e };
</PRE>

<P>This might be covered by 9.1 [<A href="https://wg21.link/dcl.pre#3">dcl.pre</A>] paragraph 3,</P>

<BLOCKQUOTE>

In a <I>simple-declaration</I>, the
optional <I>init-declarator-list</I> can be omitted only when
declaring a class (Clause 11 [<A href="https://wg21.link/class">class</A>]) or enumeration
(9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>]), that is, when
the <I>decl-specifier-seq</I> contains either
a <I>class-specifier</I>, an <I>elaborated-type-specifier</I> with a
<I>class-key</I> (11.3 [<A href="https://wg21.link/class.name">class.name</A>]), or
an <I>enum-specifier</I>. In these cases and whenever a
<I>class-specifier</I> or <I>enum-specifier</I> is present in the
<I>decl-specifier-seq</I>, the identifiers in these specifiers are
among the names being declared by the declaration
(as <I>class-name</I>s, <I>enum-name</I>s, or <I>enumerator</I>s,
depending on the syntax). In such cases, and except for the
declaration of an unnamed bit-field (11.4.10 [<A href="https://wg21.link/class.bit">class.bit</A>]), the
<I>decl-specifier-seq</I> shall introduce one or more names into the
program, or shall redeclare a name introduced by a previous
declaration.

</BLOCKQUOTE>

<P>which, when combined with paragraph 2,</P>

<BLOCKQUOTE>

A declaration occurs in a scope (6.4 [<A href="https://wg21.link/basic.scope">basic.scope</A>]); the scope
rules are summarized in 6.5 [<A href="https://wg21.link/basic.lookup">basic.lookup</A>]. A declaration that
declares a function or defines a class, namespace, template, or
function also has one or more scopes nested within it. These nested
scopes, in turn, can have declarations nested within them. Unless
otherwise stated, utterances in Clause 9 [<A href="https://wg21.link/dcl">dcl</A>] about
components in, of, or contained by a declaration or subcomponent
thereof refer only to those components of the declaration that
are <I>not</I> nested within scopes nested within the declaration.

</BLOCKQUOTE>

<P>appears to rule out the similar class definition,</P>

<PRE>
    struct { int m; };
</PRE>

<P>However, a scoped enumeration is not listed in paragraph 2 among the
constructs containing a nested scope (although 6.4.8 [<A href="https://wg21.link/basic.scope.enum">basic.scope.enum</A>]
does describe &#8220;enumeration scope&#8221;); furthermore, an
<I>enumerator-definition</I> is not formally a &#8220;nested
declaration.&#8221;  If unusable scoped enumeration definitions are to
be banned, these shortcomings in 9.1 [<A href="https://wg21.link/dcl.pre#2">dcl.pre</A>] paragraph 2
must be addressed.  (A note in 9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>] mentioning that
unnamed scoped enumerations are not allowed would also be helpful.)</P>

<P><B>Notes from the February, 2008 meeting:</B></P>

<P>The consensus was to require that the <I>identifier</I> be
present in an <I>enum-specifier</I> unless the <I>enum-key</I> is
<TT>enum</TT>.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 9.8.1 [<A href="https://wg21.link/dcl.enum#2">dcl.enum</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

...The <I>enum-key</I>s <TT>enum class</TT> and <TT>enum struct</TT>
are semantically equivalent; an enumeration type declared with one of
these is a <I>scoped enumeration</I>, and its <I>enumerator</I>s are
<I>scoped enumerators</I>. <INS>The optional <I>identifier</I> shall not be
omitted in the declaration of a scoped enumeration.</INS> The
<I>type-specifier-seq</I> of an <I>enum-base</I>...

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
