Mark, in PR c++/11987 you added a comment saying that it was a
regression.  But the more I look at it, the less I understand it.

The test case is:

==================================================
template <int dim> struct X { 
    struct I { I(); }; 
}; 
 
template <int dim> struct Y : X<dim> { 
    typedef typename X<dim>::I I; 
}; 
 
template <int dim> 
Y<dim>::I::I () {}  // note: I is nested type in X, not Y! 
 
template struct Y<1>;
==================================================

g++ currently accepts this test case.  The PR says that this test case
is invalid, and should be rejected.  But I can't figure out why.  The
function definition using a typedef is clearly OK.  Is the problem
specifically that this code declares a constructor using a template
specialization?  That is, would this code be valid C++?

==================================================
template <int dim> struct X { 
  struct I { I(); void foo(); }; 
}; 
 
template <int dim> struct Y : X<dim> { 
    typedef typename X<dim>::I I; 
}; 
 
template <int dim>
void Y<dim>::I::foo () {}

template struct Y<1>;
==================================================

(Incidentally, this test case currently gets an ICE, but that is
presumably an unrelated problem.)

Or is the problem something else?

For what it's worth, I have a simple patch which rejects this code as
invalid and passes the g++ testsuite.  But the patch seems fragile and
wrong.  While trying to make the patch correct, I realized that I
don't understand what is correct.

Thanks.

Ian

Reply via email to