public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3028: 3.0 Compiler complains about template that used to work under 2.95
@ 2001-06-01  7:26 peterson
  0 siblings, 0 replies; 8+ messages in thread
From: peterson @ 2001-06-01  7:26 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3028
>Category:       c++
>Synopsis:       3.0 Compiler complains about template that used to work under 2.95
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 01 07:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     James Peterson
>Release:        version 3.1
>Organization:
>Environment:
Linux running on AMD
>Description:
The attached program is an isolated example of a problem that we
are running into.   This code compiles with the previous g++ Linux
compiler (version 2.95.2) but fails with the x86-64 g++ compiler
(version 3.1).

The previous compiler generated no errors; the new x86-64
compiler says:

/tmp/e.C: In member function `int IListBase<ALLOC>::find(int)':
/tmp/e.C:19: non-template type `IListNode' used as a template
/tmp/e.C:19: ISO C++ forbids declaration of `node' with no type

>How-To-Repeat:

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).

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="e.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="e.C"

CnRlbXBsYXRlPGNsYXNzIEFMTE9DPiBjbGFzcyBJTGlzdEJhc2UgCnsKIHByb3RlY3RlZDoKICBz
dHJ1Y3QgSUxpc3ROb2RlIAogIHsKICAgIElMaXN0Tm9kZSAqbmV4dDsKICAgIGludCBkYXR1bTsK
ICB9OwogIAogIGNsYXNzIElMaXN0Tm9kZSAqaGVhZDsKICBjbGFzcyBJTGlzdE5vZGUgKnRhaWw7
CiAgCiAgaW50IGZpbmQoaW50IGRhdHVtKTsKfTsKCnRlbXBsYXRlPGNsYXNzIEFMTE9DPiBpbnQg
SUxpc3RCYXNlPEFMTE9DPjo6ZmluZChpbnQgZCkKewogIElMaXN0Tm9kZTxBTExPQz4gKm5vZGU7
CiAgZm9yKG5vZGUgPSBoZWFkOyBub2RlICE9IDA7IG5vZGUgPSBub2RlLT5uZXh0KQogICAgewog
ICAgICBpZihub2RlLT5kYXR1bSA9PSBkKQoJewoJICByZXR1cm4gMTsKCX0KICAgIH0KICByZXR1
cm4gMDsKfQoKCg==


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
@ 2001-06-01 18:26 Gabriel Dos Reis
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriel Dos Reis @ 2001-06-01 18:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: "Artem Khodush" <artem@duma.gov.ru>
Cc: <peterson@austin.ibm.com>, <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
Date: 02 Jun 2001 03:14:32 +0200

 | > 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;
       ^^^^^^^^^
 
 There is no template-name 'IListNode' defined at this point.  Lookup
 finds only a NON-template-name (member) name.
 
 -- Gaby


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work   under 2.95
@ 2001-06-01 18:26 Gabriel Dos Reis
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriel Dos Reis @ 2001-06-01 18:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: James L Peterson <peterson@austin.ibm.com>
Cc: Artem Khodush <artem@duma.gov.ru>, gcc-gnats@gcc.gnu.org,
   gcc-bugs@gcc.gnu.org
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work   under 2.95
Date: 02 Jun 2001 03:15:56 +0200

 James L Peterson <peterson@austin.ibm.com> writes:
 
 | I was unable to understand the template description in Stroustrup (3rd
 | edition)
 | well enough to tell if 3.0 or 2.9.5 was right.  So you may be right that
 | 3.0
 | is correct.  The argument for 3.0 being wrong is that IListNode is
 | defined
 | inside IListBase and so has to be effectively "templated" because
 | IListBase is.
 
 But GCC-3.0 is right, because IListNode is -not- a template-name.
 
 -- Gaby


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work   under 2.95
@ 2001-06-01 12:46 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2001-06-01 12:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: Alexandre Oliva <aoliva@redhat.com>
To: James L Peterson <peterson@austin.ibm.com>
Cc: Artem Khodush <artem@duma.gov.ru>, gcc-gnats@gcc.gnu.org,
        gcc-bugs@gcc.gnu.org
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work   under 2.95
Date: 01 Jun 2001 16:30:16 -0300

 On Jun  1, 2001, James L Peterson <peterson@austin.ibm.com> wrote:
 
 > It seems to me that only question would be whether or
 > not "lots of people" will run into either or both.  If you believe
 > that few people will run into this problem, then you are right.
 
 It's not a matter of belief, it's a matter of observable behavior.  I
 follow the gcc-bugs mailing list and have an idea of how often a
 non-problem is reported.  The one you cited was reported a lot, and so
 it was added to that page.  The one you report wasn't, so it's not
 there yet.
 
 -- 
 Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
 Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
 CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
 Free Software Evangelist    *Please* write to mailing lists, not to me


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work  under 2.95
@ 2001-06-01 12:26 James L Peterson
  0 siblings, 0 replies; 8+ messages in thread
From: James L Peterson @ 2001-06-01 12:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: James L Peterson <peterson@austin.ibm.com>
To: Alexandre Oliva <aoliva@redhat.com>
Cc: Artem Khodush <artem@duma.gov.ru>, gcc-gnats@gcc.gnu.org,
        gcc-bugs@gcc.gnu.org
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work  
 under 2.95
Date: Fri, 01 Jun 2001 14:17:39 -0500

 Alexandre Oliva wrote:
 
 > > If 3.0 is correct, from a language point of view, then this would be a
 > > candidate for the list of known bugs at
 > > http://gcc.gnu.org/bugs.html#known
 >
 > I beg to differ.  That page is for actual bugs, or for non-bugs that
 > lots of people perceive as bugs.  The problem you report is neither.
 
 I would suggest that this problem is the same as with the
 "G++ allows to access private types" bug.  Both
 are cases where the old compiler allows (without error)
 a construct that the new compiler does not allow.
 For those of us trying to get large bodies of C++ code
 (that work with the old compiler) to work with the 3.0
 compiler, it would help to have both of these listed
 **as problems with the old compiler**, not as
 problems with the new compiler.
 
 It seems to me that only question would be whether or
 not "lots of people" will run into either or both.  If you believe
 that few people will run into this problem, then you are right.
 
 jim
 
 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work  under 2.95
@ 2001-06-01 11:36 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2001-06-01 11:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: Alexandre Oliva <aoliva@redhat.com>
To: James L Peterson <peterson@austin.ibm.com>
Cc: Artem Khodush <artem@duma.gov.ru>, gcc-gnats@gcc.gnu.org,
        gcc-bugs@gcc.gnu.org
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work  under 2.95
Date: 01 Jun 2001 15:27:01 -0300

 On Jun  1, 2001, James L Peterson <peterson@austin.ibm.com> wrote:
 
 > The argument for 3.0 being wrong is that IListNode is defined inside
 > IListBase and so has to be effectively "templated" because IListBase
 > is.
 
 Indeed, it is templated.  And its full name is
 ::IListBase<ALLOC>::IListNode.  Note where the template argument
 goes.
 
 > If 3.0 is correct, from a language point of view, then this would be a
 > candidate for the list of known bugs at
 > http://gcc.gnu.org/bugs.html#known
 
 I beg to differ.  That page is for actual bugs, or for non-bugs that
 lots of people perceive as bugs.  The problem you report is neither.
 
 -- 
 Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
 Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
 CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
 Free Software Evangelist    *Please* write to mailing lists, not to me


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
@ 2001-06-01  8:46 James L Peterson
  0 siblings, 0 replies; 8+ messages in thread
From: James L Peterson @ 2001-06-01  8:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: James L Peterson <peterson@austin.ibm.com>
To: Artem Khodush <artem@duma.gov.ru>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work 
 under 2.95
Date: Fri, 01 Jun 2001 10:37:23 -0500

 I was unable to understand the template description in Stroustrup (3rd
 edition)
 well enough to tell if 3.0 or 2.9.5 was right.  So you may be right that
 3.0
 is correct.  The argument for 3.0 being wrong is that IListNode is
 defined
 inside IListBase and so has to be effectively "templated" because
 IListBase is.
 
 If 3.0 is correct, from a language point of view, then this would be a
 candidate for the list of known bugs at
 http://gcc.gnu.org/bugs.html#known
 (for GCC 2.95) just like the "G++ allows to access private types".
 
 jim
 
 
 Artem Khodush wrote:
 
 > >
 > > 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.
 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
@ 2001-06-01  8:16 Artem Khodush
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Khodush @ 2001-06-01  8:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3028; it has been noted by GNATS.

From: "Artem Khodush" <artem@duma.gov.ru>
To: <peterson@austin.ibm.com>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>
Subject: Re: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
Date: Fri, 1 Jun 2001 18:58:15 +0400

 > 
 > 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.
 
 
 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-06-01 18:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-01  7:26 c++/3028: 3.0 Compiler complains about template that used to work under 2.95 peterson
2001-06-01  8:16 Artem Khodush
2001-06-01  8:46 James L Peterson
2001-06-01 11:36 Alexandre Oliva
2001-06-01 12:26 James L Peterson
2001-06-01 12:46 Alexandre Oliva
2001-06-01 18:26 Gabriel Dos Reis
2001-06-01 18:26 Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).