This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
- To: <peterson at austin dot ibm dot com>
- Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
- From: "Artem Khodush" <artem at duma dot gov dot ru>
- Date: Fri, 1 Jun 2001 18:58:15 +0400
- >Received: from artem by mailsrv.duma.gov.ru (SMI-8.6/SMI-SVR4)id TAA01131; Fri, 1 Jun 2001 19:01:09 +0400
- Cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>
- References: <20010601141933.13459.qmail@sourceware.cygnus.com>
>
> 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.