Bug 19964 - [3.4/4.0/4.1 regression] ICE on invalid member declaration
Summary: [3.4/4.0/4.1 regression] ICE on invalid member declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: 4.0.3
Assignee: Nathan Sidwell
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
: 22257 (view as bug list)
Depends on:
Blocks: 24672
  Show dependency treegraph
 
Reported: 2005-02-15 00:43 UTC by Volker Reichelt
Modified: 2005-10-12 16:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-15 11:51:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2005-02-15 00:43:55 UTC
The following invalid code snippet causes an ICE since gcc 3.4.0:

==================
struct A
{
    A : A;
};
==================

bug.cc:3: error: expected primary-expression before ';' token
bug.cc:3: error: name 'A' has incomplete type
bug.cc:2: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

With the similar code snippet

==================
struct A
{
    A : B;
};
==================

I get an ICE since at least gcc 2.95.3.

bug.cc:3: error: 'B' was not declared in this scope
bug.cc:3: error: name 'A' has incomplete type
bug.cc:2: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2005-02-15 00:54:00 UTC
: Search converges between 2002-12-14-trunk (#159) and 2002-12-29-trunk (#160).

So ever since the new parser was merged in.
Comment 2 Volker Reichelt 2005-02-15 00:55:31 UTC
Btw, more segfaults can be generated with
A : A()   (since 2.95.3)
A : B()   (since 2.95.3)
A : A[]   (since 3.4.0)
A : B[]   (since 3.4.0)
Comment 3 Andrew Pinski 2005-07-22 21:13:43 UTC
Moving to 4.0.2 pre Mark.
Comment 4 GCC Commits 2005-10-12 10:59:32 UTC
Subject: Bug 19964

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2005-10-12 10:59:27

Modified files:
	gcc            : ChangeLog stor-layout.c 
	gcc/cp         : ChangeLog class.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: crash31.C 

Log message:
	PR c++/19964
	* stor-layout.c (place_field): Set DECL_FIELD_OFFSET and
	DECL_FIELD_BIT_OFFSET of FIELD_DECLs, even if they have an invalid
	type.
	cp:
	PR c++/19964
	* cp/class.c (walk_subobject_offsets): Don't walk error_mark_node.
	testsuite:
	PR c++/19964
	* g++.dg/parse/crash31.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10143&r2=2.10144
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stor-layout.c.diff?cvsroot=gcc&r1=1.244&r2=1.245
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4921&r2=1.4922
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.733&r2=1.734
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6174&r2=1.6175
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash31.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 Nathan Sidwell 2005-10-12 13:07:11 UTC
Fixed mainline and 4.0 branch
2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/19964
	* stor-layout.c (place_field): Set DECL_FIELD_OFFSET and
	DECL_FIELD_BIT_OFFSET of FIELD_DECLs, even if they have an invalid
	type.
	* cp/class.c (walk_subobject_offsets): Don't walk error_mark_node.
Comment 7 Volker Reichelt 2005-10-12 16:02:24 UTC
*** Bug 22257 has been marked as a duplicate of this bug. ***