This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
The following code, compiled with -g, causes an ICE on 4.2.0 RC3 (20070501) and on my most recent 4.3.0 snapshot build (20070427): --------------------- namespace NS { int x = 0; int &ref = x; } using NS::ref; --------------------- test/ice.cc:6: internal compiler error: in reference_to_unused, at dwarf2out.c:10128 This compiles cleanly with both 4.1.2 and 4.2.0 RC1 (20070316), suggesting that this was exposed by a fairly recent patch. Note that, in particular, this impacts code using Boost.Lambda in the following style: #include <boost/lambda/lambda.hpp> using boost::lambda::_1; ...
On your test case, $ g++-4 -g -c pr31899.cc -o pr31899.o also works for me with 4.2.0 20070430 (prerelease), which was 4.2's RC2. Configured with: ../gcc-4.2.0-20070430/configure --prefix=/sw --prefix=/sw/lib/gcc4.2 --mandir=/sw/share/man --infodir=/sw/share/info --enable-languages=c,c++,fortran,objc,java --host=powerpc-apple-darwin8 --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib
Ooops, strike that last comment, forgot -gdwarf-2: g++-4 -gdwarf-2 -c pr31899.cc -o pr31899.o ICEs with: internal compiler error: in reference_to_unused, at dwarf2out.c:10010 (same compiler version, 4.2 RC2)
Confirmed, this was caused by the patch for PR 30700.
Will not be fixed in 4.2.0; retargeting at 4.2.1.
Created an attachment (id=13989) [edit] Proposed fix for SEGV problem in dwarf2out.c in bug 31899
*** Bug 33026 has been marked as a duplicate of this bug. ***
*** Bug 33625 has been marked as a duplicate of this bug. ***
*** Bug 33580 has been marked as a duplicate of this bug. ***
else if (!cgraph_global_info_ready && (TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == FUNCTION_DECL)) gcc_unreachable (); the problem is that the C++ FE emits debug info for global using decls from parsing: ... #9 0x082a825e in cp_emit_debug_info_for_using (t=0xb7d6705c, context=0x0) at /home/richard/src/trunk/gcc/cp/name-lookup.c:5223 ---Type <return> to continue, or q <return> to quit--- #10 0x0829f5ef in do_toplevel_using_decl (decl=0xb7d61870, scope=0xb7d61798, name=0xb7d66708) at /home/richard/src/trunk/gcc/cp/name-lookup.c:3360 #11 0x081bca90 in cp_parser_using_declaration (parser=0xb7cd22a4, access_declaration_p=0 '\0') at /home/richard/src/trunk/gcc/cp/parser.c:11695 ... via the imported_module_or_decl debug hook. I guess we should simply queue these with the varpool. Or probably invent a new pool for just this use. Or just weaken the sanity check.
Created an attachment (id=14286) [edit] patch Different patch.
Subject: Bug 31899 Author: rguenth Date: Wed Oct 3 10:01:43 2007 New Revision: 128978 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128978 Log: 2007-10-03 Doug Kwan <dougkwan@google.com> Richard Guenther <rguenther@suse.de> PR debug/31899 * dwarf2out.c (reference_to_unused): Disable sanity checking, be conservative instead. * g++.dg/debug/using3.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/debug/using3.C Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk, queued for 4.2.3.
*** Bug 33668 has been marked as a duplicate of this bug. ***
Subject: Bug 31899 Author: rguenth Date: Wed Oct 10 09:29:13 2007 New Revision: 129199 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129199 Log: 2007-10-10 Richard Guenther <rguenther@suse.de> Backport from mainline 2007-10-03 Doug Kwan <dougkwan@google.com> Richard Guenther <rguenther@suse.de> PR debug/31899 * dwarf2out.c (reference_to_unused): Disable sanity checking, be conservative instead. * g++.dg/debug/using3.C: New testcase. Added: branches/gcc-4_2-branch/gcc/testsuite/g++.dg/debug/using3.C - copied unchanged from r128978, trunk/gcc/testsuite/g++.dg/debug/using3.C Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/dwarf2out.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
Fixed.
*** Bug 35391 has been marked as a duplicate of this bug. ***