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: c++/3028: 3.0 Compiler complains about template that used to work under 2.95


> 
> template<class ALLOC> class IListBase 
> {
>  protected:
>   struct IListNode 
>   {
>     IListNode *next;
>     int datum;
>   };
>   
>   class IListNode *head;
>   class IListNode *tail;
>   
>   int find(int datum);
> };
> 
> template<class ALLOC> int IListBase<ALLOC>::find(int d)
> {
>   IListNode<ALLOC> *node;
>   for(node = head; node != 0; node = node->next)
>     {
>       if(node->datum == d)
> {
>   return 1;
> }
>     }
>   return 0;
> }
> 
> 
> >Fix:
> A workaround seems to be to move the inner node class
> out of the template list class and make it its own template
> (but that breaks the protection).

Well, the code works if <ALLOC> after the IListNode is omitted.
I believe gcc 3.0 is right, IListNode is indeed not a template.




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