This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


591. When a dependent base class is the current instantiation

Section: 13.8.3  [temp.dep]     Status: CD4     Submitter: James Widman     Date: 24 August 2006

[Moved to DR at the November, 2014 meeting.]

Is the following example well-formed?

    template<class T> struct A {
         typedef int M;
         struct B {
             typedef void M;
             struct C;
         };
    };

    template<class T> struct A<T>::B::C : A<T> {
         M  // A<T>::M or A<T>::B::M?
             p[2];
    };

13.8.3 [temp.dep] paragraph 3 says the use of M should refer to A<T>::B::M because the base class A<T> is not searched because it's dependent. But in this case A<T> is also the current instantiation (13.8.3.2 [temp.dep.type]) so it seems like it should be searched.

Notes from the August, 2011 meeting:

The recent changes to the handling of the current instantiation may have sufficiently addressed this issue.

Additional note (September, 2012):

See also issue 1526 for additional analysis demonstrating that this issue is still current despite the changes to the description of the current instantiation. The status has consequently been changed back to "open" for further consideration.

Proposed resolution (February, 2014):

  1. Add the following as a new paragraph before 13.8.3.2 [temp.dep.type] paragraph 4:

  2. A dependent base class is a base class that is a dependent type and is not the current instantiation. [Note: a base class can be the current instantiation in the case of a nested class naming an enclosing class as a base. —end note] [Example:

      template<class T> struct A {
        typedef int M;
        struct B {
          typedef void M;
          struct C;
        };
      };
    
      template<class T> struct A<T>::B::C : A<T> {
        M m; // OK, A<T>::M
      };
    

    end example]

    A name is a member of the current instantiation if...

  3. Change 13.8.2 [temp.local] paragraph 9 as follows:

  4. In the definition of a class template or in the definition of a member of such a template that appears outside of the template definition, for each non-dependent base class (13.8.3.2 [temp.dep.type]) which does not depend on a template-parameter (13.8.3 [temp.dep]), if the name of the base class or the name of a member of the base class is the same as the name of a template-parameter, the base class name or member name hides the template-parameter name (_N4868_.6.4.10 [basic.scope.hiding]). [Example:...
  5. Change 13.8.3 [temp.dep] paragraph 3 as follows:

  6. In the definition of a class or class template, if a base class depends on a template-parameter, the base class scope the scope of a dependent base class (13.8.3.2 [temp.dep.type]) is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of the class template or member. [Example:...