Bug 65496

Summary: gcc3 crashes when compiling template-intensive code.
Product: [Retired] Red Hat Linux Reporter: Gary Huber <ghuber>
Component: gcc3Assignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-02 20:46:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gary Huber 2002-05-25 22:24:14 UTC
When compiling some template-intensive code, I get:

[ghuber@josquin basic]$ gcc3 -c bug.cc 
bug.cc:29: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Get code (bug.cc)
2. gcc3 -c bug.cc -v
3.
	

Actual Results:  [ghuber@josquin basic]$ gcc3 -c bug.cc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.0.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib
Thread model: posix
gcc version 3.0.4 (Red Hat Linux 7.2 3.0.4-1)
 /usr/lib/gcc-lib/i386-redhat-linux/3.0.4/cc1plus -v -D__GNUC__=3
-D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D__ELF__ -Dunix -Dlinux -D__ELF__
-D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__
-D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386
-D__i386__ -D__tune_i386__ bug.cc -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS
-D__GXX_ABI_VERSION=100 -quiet -dumpbase bug.cc -version -o /tmp/ccQkjLW7.s
GNU CPP version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (i386-redhat-linux)
	compiled by GNU C version 3.0.4 (Red Hat Linux 7.2 3.0.4-1).
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-v3
 /usr/include/g++-v3/i386-redhat-linux
 /usr/include/g++-v3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.0.4/include
 /usr/include
End of search list.
bug.cc:29: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.


Expected Results:  I probably should have gotten error messages without the
compiler
crashing.

Additional info:

// bug.cc


template< class H, class T>
struct Pair;

template< bool Q, class R0, class R1>
struct If;

template< class R, class T>
struct Trait;

template< class R, class L>
struct Pair_Trait{
  
  static const bool gone_up = false; 

  typedef 
  typename If< 
    gone_up, int, int
   >::Result 
   Result;
};  

template< class R, class H, class T>
struct Trait< R, Pair< H, T> >{
  
  typedef Pair_Trait< R, Pair< H,T> >::Result::Head
  Result;
};

Comment 1 Alan Cox 2002-12-15 20:37:21 UTC
Confirmed still present in g++ 3.2 on 8.0


Comment 2 Richard Henderson 2004-10-02 20:46:37 UTC
GCC 3.4 no longer ICEs.  As written, the test case is missing a 
typename for the typedef in Trait, but after fixing that the test
compiles without complaint.