This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR c++/11987: why is it invalid?


Ian Lance Taylor wrote:
> 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.

I forget the chapter-and-verse, but the point is that I is nested in X,
and so to *define* its constructor (as opposed to refer to it), you have
to say X<dim>::I::I().

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]