cplusplus / cplusplus/draft

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

Open
#4,409 0 comments 0 reactions 1 assignee View on GitHub

@jensmaurer is already working on this.

Since Dec 14, 2020.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[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.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.