Bug 31749 - [4.2 regression] ICE with invalid redeclaration of builtin
Summary: [4.2 regression] ICE with invalid redeclaration of builtin
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Ollie Wild
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2007-04-29 12:11 UTC by Volker Reichelt
Modified: 2009-03-30 21:45 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.5
Last reconfirmed: 2007-05-22 22:41:08


Attachments
Fix for PR 31749. (3.04 KB, patch)
2007-08-06 23:17 UTC, Ollie Wild
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-04-29 12:11:13 UTC
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.]
Comment 1 Ollie Wild 2007-04-30 22:47:23 UTC
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.
Comment 2 Ollie Wild 2007-05-01 00:24:51 UTC
Never mind.  The first snippet triggers the specified error as well.  Not quite sure what I did...
Comment 3 Ollie Wild 2007-05-22 22:41:08 UTC
Assigning to myself since I now have write access to Bugzilla.
Comment 4 Andrew Pinski 2007-08-06 15:12:59 UTC
I no longer get a segfault for the trunk for the first testcase.
Comment 5 Ollie Wild 2007-08-06 21:24:25 UTC
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.
Comment 6 Ollie Wild 2007-08-06 23:17:46 UTC
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.
Comment 7 patchapp@dberlin.org 2007-08-07 19:15:37 UTC
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
Comment 8 Ollie Wild 2007-08-17 21:42:51 UTC
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

Comment 9 Ollie Wild 2007-08-18 06:26:20 UTC
Fixed by change 127600.
Comment 10 Andrew Pinski 2007-08-18 09:07:02 UTC
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).
Comment 11 Joseph S. Myers 2008-07-04 22:01:52 UTC
Closing 4.1 branch.
Comment 12 Joseph S. Myers 2009-03-30 21:45:28 UTC
Closing 4.2 branch, fixed in 4.3.