This is the mail archive of the gcc-bugs@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]

RE: gcc 2.95.2 ICE with templates


Thanks for the explanation!

Now, if I understand this matter correctly I have a related code example below, that
is faulty and should NOT compile (which it does with gcc 2.95.2).
Do you know if a recent snapshot complains about this code?

Regards, Peter

/*--------------------*/
template <typename SINGLETON, typename MANAGER> class SingletonTraits { };

template <typename SINGLETON, typename MANAGER> 
class Singleton { 
public:
  typedef typename 
    SingletonTraits<SINGLETON, MANAGER>::InstantiatorType InstantiatorType;
};

class NoCleanupMgr2 { 
public:
  class H {};
};

// Traits class
//
template <typename SINGLETON>
struct SingletonTraits<SINGLETON, NoCleanupMgr2>  {
  typedef NoCleanupMgr2::H InstantiatorType;
};


class S: public Singleton<S, NoCleanupMgr2> {
  friend class Singleton<S, NoCleanupMgr2>::InstantiatorType;
};

int main(){
  S s;
  return 0;
}


----- Original Message ----- 
From: Martin v. Loewis <martin@loewis.home.cs.tu-berlin.de>
To: <peter_nordlund@swipnet.se>
Cc: <gcc-bugs@gcc.gnu.org>
Sent: Wednesday, February 23, 2000 9:57 AM
Subject: Re: gcc 2.95.2 ICE with templates


> > I do not understand the error message, do you by any chanse know
> > what is wrong with my code example?
> 
> The 'class' you declare as a friend is not a class, but a
> typedef-name. You must not use a typedef-name in an elaborated type
> specifier, not even in a friend declaration. If you write
> 
>   friend class NoCleanupMgr2;
> 
> even g++ 2.95 compiles it fine.
> 
> Regards,
> Martin
> 


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