The following invalid code snippet triggers a segfault since GCC 3.1: ======================== namespace std { union abort; } void abort(); using std::abort; ======================== bug.cc:8: internal compiler error: Segmentation fault Please submit a full bug report, [etc.] Compiling the code with "-fno-builtin" yields: bug.cc:8: error: 'abort' is already declared in this scope A slightly different testcase triggers the following ICE: ======================== namespace std { union abort; } union abort; using std::abort; ======================== bug.cc:8: internal compiler error: tree check: expected class 'type', have 'declaration' (type_decl) in comptypes, at cp/typeck.c:1115 Please submit a full bug report, [etc.]
The first code snippet compiles fine with the trunk and gcc-4.1.1. Volker, are you sure the code snippet is correct? The second snippet does indeed generate the specified error.
Never mind. The first snippet triggers the specified error as well. Not quite sure what I did...
Assigning to myself since I now have write access to Bugzilla.
I no longer get a segfault for the trunk for the first testcase.
No segfault, but it does give an "is already declared in this scope" error. Contrary to the claim in the initial bug submission, this is valid code. From paragraph 10, section 7.3.3 of the C++ standard: Since a using-declaration is a declaration, the restrictions on declarations of the same name in the same declarative region (3.3) also apply to using-declarations.
Created attachment 14030 [details] Fix for PR 31749. This patches fixes this PR and includes some ambiguous decl cleanup as well. Submission pending completion of full testsuite.
Subject: Bug number PR c++/31749 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00452.html
Subject: Bug 31749 Author: aaw Date: Fri Aug 17 21:42:38 2007 New Revision: 127600 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127600 Log: PR c++/31749 gcc/cp/ * name-lookup.c (do_nonmember_using_decl): Shift implicit type declarations into appropriate slots for comparison. Fix type comparison. gcc/testsuite/ * g++.dg/lookup/builtin3.C: New test. * g++.dg/lookup/builtin4.C: New test. * g++.dg/lookup/using19.C: New test. Added: trunk/gcc/testsuite/g++.dg/lookup/builtin3.C trunk/gcc/testsuite/g++.dg/lookup/builtin4.C trunk/gcc/testsuite/g++.dg/lookup/using19.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/name-lookup.c trunk/gcc/testsuite/ChangeLog
Fixed by change 127600.
No, this was only fixed for the trunk, this is still not fixed for the 4.2 branch or 4.1 branch (it is a regression after all).
Closing 4.1 branch.
Closing 4.2 branch, fixed in 4.3.