Created on 2012-07-03.00:00:00 last changed 122 months ago
[Moved to DR at the September, 2013 meeting.]
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]
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 (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]
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | status: drwp -> c++14 |
2014-03-03 00:00:00 | admin | set | status: dr -> drwp |
2013-10-14 00:00:00 | admin | set | messages: + msg4692 |
2013-10-14 00:00:00 | admin | set | status: tentatively ready -> dr |
2013-09-03 00:00:00 | admin | set | messages: + msg4461 |
2013-09-03 00:00:00 | admin | set | status: drafting -> tentatively ready |
2013-05-03 00:00:00 | admin | set | messages: + msg4337 |
2013-05-03 00:00:00 | admin | set | status: tentatively ready -> drafting |
2012-11-03 00:00:00 | admin | set | messages: + msg4076 |
2012-11-03 00:00:00 | admin | set | status: open -> tentatively ready |
2012-07-03 00:00:00 | admin | create |