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

[class.mem.general]/12 seems to conflict with [class.nest]/3 #4409

Open
cpplearner opened this issue Dec 6, 2020 · 0 comments · May be fixed by #4416
Open

[class.mem.general]/12 seems to conflict with [class.nest]/3 #4409

cpplearner opened this issue Dec 6, 2020 · 0 comments · May be fixed by #4416
Assignees

Comments

@cpplearner
Copy link
Contributor

[class.mem.general]/12:

The member-declarator-list can be omitted only after a class-specifier or an enum-specifier or in a friend declaration.

[class.nest]/3:

If class X is defined in a namespace scope, a nested class Y may be declared in class X and later defined in the definition of class X or be later defined in a namespace scope enclosing the definition of class X.

Consider

class E {
  class I1;                     // forward declaration of nested class
};

AFAIK, class I1; is a member-declaration with an elaborated-type-specifier and no member-declarator-list. According to [class.mem.general]/12, this is not permitted because there's no class-specifier or enum-specifier or friend. But [class.nest]/3 seems to suggest that it's valid. (How else can one declare but not define a class name in a class scope?)

I believe it's obvious that the example in question is valid, and [class.mem.general]/12 needs to account for elaborated-type-specifier. (Maybe it should use similar wording as in [dcl.pre]/5.)

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

Successfully merging a pull request may close this issue.

2 participants