Bug 6289 - ICE in pop_binding while befriending a typedef of a builtin
Summary: ICE in pop_binding while befriending a typedef of a builtin
Status: RESOLVED DUPLICATE of bug 7983
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.0.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
: 8903 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-04-13 15:06 UTC by jototland
Modified: 2003-08-02 20:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-06-23 12:49:33


Attachments
minimal.cc (142 bytes, application/octet-stream)
2003-05-21 15:16 UTC, jototland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jototland 2002-04-13 15:06:09 UTC
While doing something tricky with templates I got an internal compiler error.

jo@bogon:~/units$ g++-3.0 -ansi -Wall -c minimal.cc
minimal.cc:15: warning: `class my_frobnicator' declares a new type at namespace 
   scope;
   to refer to the inherited type, say `class foo::type'
   (names from dependent base classes are not visible to unqualified name 
   lookup)
minimal.cc:17: Internal compiler error in pop_binding, at cp/decl.c:1186
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

A minimal test program that triggers the bug is included.

Release:
g++ 3.0.4, g++ 2.95.4

Environment:
Debian testing distribution, self-compiled linux kernel version 2.4.18

How-To-Repeat:
recompile the included test-program
Comment 1 jototland 2002-04-13 15:06:09 UTC
Fix:
no idea
Comment 2 Volker Reichelt 2002-05-08 00:42:23 UTC
From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, jototland@hotmail.com, gcc-bugs@gcc.gnu.org,
        nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/6289: partial template specialization and friend
Date: Wed, 8 May 2002 00:42:23 +0200

 Hi,
 
 the testcase can be reduced even further to the following code snippet
 which still crashes gcc 3.1 as of 20020506.
 
 ---------------------------snip here--------------------------
 struct A
 {
     typedef int type;
 };
 
 template <typename T>
 class B
 {
     typedef A::type X;
     friend class X;
 };
 ---------------------------snip here--------------------------
 
 Greetings,
 Volker Reichelt
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6289
 
 

Comment 3 Wolfgang Bangerth 2002-05-08 10:36:26 UTC
From: Wolfgang Bangerth <bangerth@math.ethz.ch>
To: reichelt@igpm.rwth-aachen.de, <gcc-gnats@gcc.gnu.org>,
        <jototland@hotmail.com>, <gcc-bugs@gcc.gnu.org>
Cc:  
Subject: Re: c++/6289: partial template specialization and friend
Date: Wed, 8 May 2002 10:36:26 +0200 (CEST)

 > the testcase can be reduced even further to the following code snippet
 > which still crashes gcc 3.1 as of 20020506.
 >
 > ---------------------------snip here--------------------------
 > struct A
 > {
 >    typedef int type;
 > };
 >
 > template <typename T>
 > class B
 > {
 >    typedef A::type X;
 >    friend class X;
 > };
 > ---------------------------snip here--------------------------
 
 This is illegal, by the way, as a _real_ class is expected in a friend 
 declaration, not a typedef. Someone may reclassify this bug as 
 ice-on-illegal then.
 
 Regards
   Wolfgang
 
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth                  email:           bangerth@math.ethz.ch
                                    www: http://www.math.ethz.ch/~bangerth
 
 

Comment 4 Nathan Sidwell 2002-05-08 12:34:04 UTC
From: Nathan Sidwell <nathan@acm.org>
To: Reichelt <reichelt@igpm.rwth-aachen.de>
Cc: gcc-gnats@gcc.gnu.org, jototland@hotmail.com, gcc-bugs@gcc.gnu.org, 
    nobody@gcc.gnu.org, bangerth@math.ethz.ch
Subject: Re: c++/6289: partial template specialization and friend
Date: Wed, 08 May 2002 12:34:04 +0100

 Reichelt wrote:
 > 
 > Hi,
 > 
 > here's an even shorter example:
 > 
 > ---------------------------snip here--------------------------
 > template <typename T> class B
 > {
 >     typedef int X;
 >     friend class X;
 > };
 > ---------------------------snip here--------------------------
 > 
 > This is in fact legal code (and is accepted by SGI's and Comeau's
 > compiler for example). It would be illegal, if the friend declaration
 no it is ill formed. [7.1.5.3]/2 says
 	if the identifier resolves to a typedef name, or a template
 	type-parameter, the elaborated type specifier is ill-formed.
 
 nathan
 
 -- 
 Dr Nathan Sidwell :: Computer Science Department :: Bristol University
            The voices in my head told me to say this
 nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
Comment 5 Volker Reichelt 2002-05-08 12:52:10 UTC
From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, jototland@hotmail.com, gcc-bugs@gcc.gnu.org,
        nobody@gcc.gnu.org, bangerth@math.ethz.ch
Cc:  
Subject: Re: c++/6289: partial template specialization and friend
Date: Wed, 8 May 2002 12:52:10 +0200

 Hi,
 
 here's an even shorter example:
 
 ---------------------------snip here--------------------------
 template <typename T> class B
 {
     typedef int X;
     friend class X;
 };
 ---------------------------snip here--------------------------
 
 This is in fact legal code (and is accepted by SGI's and Comeau's
 compiler for example). It would be illegal, if the friend declaration
 read "friend class B<T>::X", but this way "friend class X" refers to a
 class outside of B (which hasn't been defined yet). If you add
 "class X;" before the definiton of B then the ICE vanishes.
 
 Greetings,
 Volker Reichelt
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6289
 
 

Comment 6 Kriang Lerdsuwanakij 2002-05-14 08:10:57 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: As suggested in the follow up.
Comment 7 Volker Reichelt 2003-08-02 20:51:35 UTC
Btw, the bug is fixed on mainline.

*** This bug has been marked as a duplicate of 7983 ***