Title
Use of derived class name in defining base class nested class
Status
nad
Section
11.4.12 [class.nest]
Submitter
Jason Shirk

Created on 2002-03-21.00:00:00 last changed 186 months ago

Messages

Date: 2008-07-15.00:00:00

Rationale (July, 2008):

The wording in Clause 11 [class] paragraph 10 (added by the resolution of issue 284, which was approved after this issue was raised) makes the example ill-formed:

If a class-head contains a nested-name-specifier, the class-specifier shall refer to a class that was previously declared directly in the class or namespace to which the nested-name-specifier refers (i.e., neither inherited nor introduced by a using-declaration), and the class-specifier shall appear in a namespace enclosing the previous declaration.
Date: 2022-11-20.07:54:16

11.4.2 [class.mfct] paragraph 5 says this about member functions defined lexically outside the class:

the member function name shall be qualified by its class name using the :: operator

11.4.9.3 [class.static.data] paragraph 2 says this about static data members:

In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the :: operator

I would have expected similar wording in 11.4.12 [class.nest] paragraph 3 for nested classes. Without such wording, the following seems to be legal (and is allowed by all the compilers I have):

  struct base {
    struct nested;
  };

  struct derived : base {};
  struct derived::nested {};

Is this just an oversight, or is there some rationale for this behavior?

History
Date User Action Args
2009-08-03 00:00:00adminsetstatus: review -> nad
2008-03-17 00:00:00adminsetmessages: + msg1603
2008-03-17 00:00:00adminsetstatus: open -> review
2002-03-21 00:00:00admincreate