Bug 260 - internal (c++) compiler error for unbound friend class template in a
Summary: internal (c++) compiler error for unbound friend class template in a
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2000-05-28 15:16 UTC by martin
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martin 2000-05-28 15:16:01 UTC
 Original-Message-ID: <39316AE0.23BA3EF4@miba.auc.dk>
 Date: Sun, 28 May 2000 20:52:16 +0200

 [the first issues is fixed in 2.96, the second one remains - MvL]

 Hello,

 I've found a bug in gcc 2.95.2 that is not present in egcs-2.91.66.
 Here's some information about it. Feel free to e-mail me questions, if
 you have any.

 Bug summary:
 gcc 2.95.2 reports an internal compiler error if:
  - A class template declares itself as an unbound friend class template
  - The declaration is in a namespace

 The problem goes away if the unbound friend template class is not the
 class itself, or if the sorrounding namespace declaration is removed,
 such that the declaration appears in the global namespace.


 I've tried it on two separate installations, and the results are
 summarized below.

 Common for both test cases:

 Command:
   g++ -Wall -g -c tst.cpp


 Compiler output ( g++ -Wall -g -c tst.cpp ):
   tst.cpp:6: Internal compiler error.
   tst.cpp:6: Please submit a full bug report.
   tst.cpp:6: See
 <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for
 instructions.


 Source example:
   namespace nsn {

     template< class Type >
     class Test {
       template< class T2 >
       friend class Test ;
     };

   } // namespace 


 Test setups (Mandrake linux/gcc 2.95.2  and IRIX 6.5/gcc 2.95.2):


 Mandrake linux:
   gcc --version
   2.95.2

   uname -a
   Linux linux1.compile.sourceforge.net 2.2.14-mosix #6 SMP Mon Feb 7
 04:11:24 PST 2000 i686 unknown

 IRIX:
   gcc --version
   2.95.2

   uname -a
   IRIX64 alzheimer 6.5 07151432 IP27




 Incidently,

 class Test {
   template< class T2 >
   friend class Test ;
 };

 seems to generate an internal compiler error, regardless of whether it
 is declared in a namespace or not. I know it's bogus-code, but it still
 shouldn't cause an internal compiler error, right :-)

Release:
2.95.2

Unformatted:
  namespace
Comment 1 Neil Booth 2001-01-14 13:42:30 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Your first example compiles without diagnostics.
    
    Your second produces (with CVS G++)
    
    bash-2.04$ g++ /tmp/test.C 
    /tmp/test.C:3: `class Test' is not a template
    bash-2.04$
Comment 2 Neil Booth 2001-01-14 21:42:30 UTC
From: neil@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de,
  nobody@gcc.gnu.org, thomas@miba.auc.dk
Cc:  
Subject: Re: c++/260
Date: 14 Jan 2001 21:42:30 -0000

 Synopsis: internal (c++) compiler error for unbound friend class template in a
 
 State-Changed-From-To: analyzed->closed
 State-Changed-By: neil
 State-Changed-When: Sun Jan 14 13:42:30 2001
 State-Changed-Why:
     Your first example compiles without diagnostics.
     
     Your second produces (with CVS G++)
     
     bash-2.04$ g++ /tmp/test.C 
     /tmp/test.C:3: `class Test' is not a template
     bash-2.04$
     
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=260&database=gcc