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

[basic.def.odr] Validity of duplicate enumerators CWG2530 #4788

Open
xmh0511 opened this issue Aug 2, 2021 · 3 comments
Open

[basic.def.odr] Validity of duplicate enumerators CWG2530 #4788

xmh0511 opened this issue Aug 2, 2021 · 3 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Aug 2, 2021

enum class A{
    a = 0,
    a = 1
};

[basic#pre-5.12] specifies that an enumerator-definition is a declaration. According to [basic.link#8], they declare the same entity. For this example, the major implementations report that "redefinition of enumerator 'a'"., however, [basic.def.odr#1] didn't mention enumerators

No translation unit shall contain more than one definition of any variable, function, class type, enumeration type, template, default argument for a parameter (for a function in a given scope), or default template argument.

Does the rule omit such a case? Also, ask the clarification of this case in this issue.

@xmh0511 xmh0511 changed the title The Odr restrictions didn't apply to enumerators The odr restrictions didn't apply to enumerators Aug 2, 2021
@jensmaurer
Copy link
Member

jensmaurer commented Aug 20, 2021

There's also a question about

enum A { x };
enum B { x };

http://lists.isocpp.org/core/2021/08/11347.php

@jensmaurer jensmaurer changed the title The odr restrictions didn't apply to enumerators [basic.def.odr] Validity of duplicate enumerators Aug 20, 2021
@jensmaurer
Copy link
Member

The first case is probably a defect.
The second case is handled by [basic.scope.scope] p4

The name ::x "is bound to two declarations that potentially conflict",
because the declarations for A::x and B::x "cause their shared name to
denote different entities".

@jensmaurer jensmaurer added cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. labels Aug 20, 2021
@jensmaurer jensmaurer changed the title [basic.def.odr] Validity of duplicate enumerators [basic.def.odr] Validity of duplicate enumerators CWG2530 Feb 19, 2022
@jensmaurer
Copy link
Member

See CWG2530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

2 participants