public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: peterson@austin.ibm.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/3028: 3.0 Compiler complains about template that used to work under 2.95
Date: Fri, 01 Jun 2001 07:26:00 -0000	[thread overview]
Message-ID: <20010601141933.13459.qmail@sourceware.cygnus.com> (raw)

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


             reply	other threads:[~2001-06-01  7:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01  7:26 peterson [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010601141933.13459.qmail@sourceware.cygnus.com \
    --to=peterson@austin.ibm.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).