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
[Moved to DR at the September, 2013 meeting.]
Consider an example like:
struct S {
typedef int T;
enum E : T {};
enum E : T {}; // #1
};
The declaration at #1 is ambiguous: it could either be an invalid redefinition of enum E or a zero-length bit-field of type enum E (since T{} is zero-valued constant expression). The current Standard does not appear to have a rule to disambiguate the two.
Proposed resolution (October, 2012) [superseded]:
Change 9.7.1 [dcl.enum] paragraph 1 as follows:
...the attributes in that attribute-specifier-seq are thereafter considered attributes of the enumeration whenever it is named. In a member-specification, an ambiguity can arise from the similarity between the declaration of an enumeration with an enum-base and the declaration of a zero-length unnamed bit-field of enumeration type. The ambiguity appears as a choice between an enum-specifier and a member-declaration for a bit-field. The resolution is that a : following enum identifier is parsed as part of an enum-base. [Example:
struct S { enum E : int {}; enum E : int {}; // error: redeclaration of enumeration };
—end example]
Notes from the April, 2013 meeting:
The ambiguity does not occur only with an empty set of braces but also when there is a single identifier that could be taken as the name of a constant in a containing scope or the declaration of an enumerator.
The resolution above sounds as if it is to be applied only if an ambiguity occurs; it should instead be always applied.
Proposed resolution (June, 2013):
Change 9.7.1 [dcl.enum] paragraph 1 as follows:
...the attributes in that attribute-specifier-seq are thereafter considered attributes of the enumeration whenever it is named. A : following “enum identifier” is parsed as part of an enum-base. [Note: This resolves a potential ambiguity between the declaration of an enumeration with an enum-base and the declaration of an unnamed bit-field of enumeration type. [Example:
struct S { enum E : int {}; enum E : int {}; // error: redeclaration of enumeration };
—end example] —end note]