Bug 859203

Summary: gcc internal compiler error: segmentation fault
Product: [Fedora] Fedora Reporter: Kyle Liddell <bugs>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: jakub, law
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-21 09:49:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
c++ source to trigger bug
none
c++ source to trigger bug
none
c++ source to trigger bug none

Description Kyle Liddell 2012-09-20 19:27:26 UTC
Created attachment 615080 [details]
c++ source to trigger bug

Description of problem:
When compiling slightly messy C++ source, g++ segfaults when generating code with debugging symbols.
I found this bug while working on a C++ project, and I was able to strip down the code to a minimal (52 line) test case.  Note that in the main.cpp file, if you take out any of the useless header includes, the error doesn't occur.  Or, if you comment out the typedef in inc.h, you also avoid the error.

I have tested this on Fedora 17 on i686 and x86_64, and on Fedora 15 on x86_64.

Version-Release number of selected component (if applicable):
gcc-c++-4.7.0-5.fc17.x86_64 ( gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) )
gcc-c++-4.6.3-2.fc15.x86_64 ( gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC) )
gcc-c++-4.7.0-5.fc17.i686 ( gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) )

How reproducible:
always

Steps to Reproduce:
On an x86_64 system:
g++ -m64 -c -o main.o main.cpp -I. -g   #segfault
g++ -m64 -c -o main.o main.cpp -I.      #compiles without error
g++ -m32 -c -o main.o main.cpp -I. -g   #error but no segfault
g++ -m32 -c -o main.o main.cpp -I.      #error but no segfault

On an i686 system:
g++ -m32 -c -o main.o main.cpp -I. -g   #segfault
g++ -m32 -c -o main.o main.cpp -I.      #compiles without error
  
Actual results:
For example, on the x86_64 system, after running
g++ -m64 -c -o main.o main.cpp -I. -g :

In file included from main.cpp:5:0:
inc.h: In instantiation of ‘union badclass<int>::buggystuff_u’:
inc.h:11:8:   required from ‘class badclass<int>’
main.cpp:7:15:   required from here
inc.h:9:12: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccDlvEg5.out file, please attach this to your bugreport.

When the compiler exits with an error message, here's the output.  (This is from x86_64, with -m32 -g )
In file included from main.cpp:5:0:
inc.h: In instantiation of ‘union badclass<int>::buggystuff_u’:
inc.h:11:8:   required from ‘class badclass<int>’
main.cpp:7:15:   required from here
inc.h:10:10: error: ‘badclass<T>::buggystuff_u::asdf’ has incomplete type
inc.h:9:12: error: declaration of ‘union badclass<int>::buggystuff_u’

Expected results:
clean compilation or an error message.

Additional info:
I don't have a machine available to generate 64bit code from a 32bit system, so I can't test that configuration.

Comment 1 Kyle Liddell 2012-09-20 19:27:56 UTC
Created attachment 615081 [details]
c++ source to trigger bug

Comment 2 Kyle Liddell 2012-09-20 19:28:33 UTC
Created attachment 615082 [details]
c++ source to trigger bug

Comment 3 Jakub Jelinek 2012-09-21 09:49:53 UTC
Handling upstream.