This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115a. See for the official list.


347. Use of derived class name in defining base class nested class

Section: 11.4.12  [class.nest]     Status: NAD     Submitter: Jason Shirk     Date: 21 March 2002

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 [] 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?

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.