Bug 9311 - [3.3 regression] ICE on illegal code using templates and inheritance
Summary: [3.3 regression] ICE on illegal code using templates and inheritance
Status: RESOLVED DUPLICATE of bug 5754
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.1
: P3 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-01-14 08:46 UTC by neil.ferguson
Modified: 2003-06-24 16:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-06-02 09:09:06


Attachments
failure.cxx (108 bytes, text/x-c++ )
2003-05-21 15:17 UTC, neil.ferguson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description neil.ferguson 2003-01-14 08:46:01 UTC
The attached (very small) source file causes an ICE when 
compiled. It defines two class templates, A and B, then 
tries to define class C as an inner class of B, inheriting 
from A. However, the definition of B does not include a 
declaration of C. 

Deleting the inheritance from A allows the compiler to 
correctly output this error: 

failure.cxx:17: invalid definition of qualified type `B<T>::C'
failure.cxx:17: `struct B<T>::<anonymous>' does not declare a template type

Uncommenting the declaration of C in B produces legal 
code, which the compiler compiles without trouble.

Release:
gcc version 3.2.1

Environment:
g++ -v:

Reading specs from /users/nf50041/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs
Configured with: ../gcc-3.2.1-original/configure --prefix=/users/nf50041 --with-gnu-as --with-gnu-ld --enable-languages=c,c++
Thread model: posix
gcc version 3.2.1

Also using binutils-2.13.1; uname -a gives: 

SunOS waverley 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-5_10

and the architecture is (Ultra) sparc32.

How-To-Repeat:
Run: 

g++ -c failure.cxx

and you should get: 

failure.cxx:17: internal error: Segmentation Fault
Comment 1 neil.ferguson 2003-01-14 08:46:01 UTC
Fix:
None known (write legal code :-)
Comment 2 Wolfgang Bangerth 2003-01-14 08:53:30 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. The code ICEs with 3.0, 3.2 and 3.3. It produced
    a useful error with 2.95, and with present 3.4.
    
    Here's the code, for simpler cut-n-pasting:
    -----------------------
    template<typename T> class A {};
    
    template<typename T> class B {}; 
    
    template<typename T>
    class B<T>::C : public A<T> {}; 
    -----------------------
    
    W.
Comment 3 Mark Mitchell 2003-06-24 16:02:27 UTC

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