Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type of an enumerator in the declaration of its enumeration #1483

Closed
bterrier opened this issue Feb 21, 2017 · 2 comments
Closed

Type of an enumerator in the declaration of its enumeration #1483

bterrier opened this issue Feb 21, 2017 · 2 comments

Comments

@bterrier
Copy link

From "Type of an enumerator in the declaration of its enum" question on stack overflow, it seems that

5.1.4.2/4

A nested-name-specifier that denotes an enumeration (7.2), followed by the name of an enumerator of that
enumeration, is a qualified-id that refers to the enumerator. The result is the enumerator. The type of the result is the type of the enumeration. The result is a prvalue.

Contradicts
7.2/5

If the underlying type is fixed, the type of each enumerator prior to the closing brace is the underlying type.

"A qualified-id that refers to the enumerator" cannot be both "the enumerator" and have "the type of the enumeration". In particular before the closing brace.

Or it would mean:

enum class E : short {
    A,
    B = A, // Works because A and B types are "short"
    C = E::A // Does not work because C type is "short" but E::A type is "E" (but E::A is A and A type is short ???)
};

Isn't "The result is the enumerator." statement in 5.1.4.2/4 enough to fix the type without ambiguity and without requiring "The type of the result is the type of the enumeration." ?

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 21, 2017

This repository and its issue tracker are for editorial issues. If you have concerns about the normative content of the Standard, you will find instructions on how to report those in the readme and the links therein.

@bterrier
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants