Bug 20461 - [4.0 Regression] ICE at "class 'C' does not have any field named 'f'" error
Summary: [4.0 Regression] ICE at "class 'C' does not have any field named 'f'" error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 4.0.0
Assignee: Paolo Carlini
URL:
Keywords: error-recovery, ice-on-invalid-code, patch
: 20536 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-03-13 21:19 UTC by wanderer
Modified: 2005-03-22 09:30 UTC (History)
4 users (show)

See Also:
Host: i386-unknown-freebsd5.3
Target: i386-unknown-freebsd5.3
Build: i386-unknown-freebsd5.3
Known to work:
Known to fail:
Last reconfirmed: 2005-03-13 21:22:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wanderer 2005-03-13 21:19:14 UTC
gcc version 4.1.0 20050313 (experimental) crash at invalid C++ code:

test.cc:3: error: invalid use of undefined type 'struct C'
test.cc:1: error: forward declaration of 'struct C'
test.cc: In constructor 'C::C()':
test.cc:3: error: class 'C' does not have any field named 'f'
test.cc:3: internal compiler error: Segmentation fault

Testcase:

--8X----------------------------
class C;

C::C() : f() {}
--X8----------------------------
Comment 1 Andrew Pinski 2005-03-13 21:22:33 UTC
Confirmed.
Comment 2 Andrew Pinski 2005-03-13 22:16:00 UTC
Backtrace:
#0  emit_mem_initializers (mem_inits=0x0) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/init.c:
485
#1  0x080eaf8f in cp_parser_ctor_initializer_opt_and_function_body (parser=0xb7c82c64)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:7665
#2  0x080eb237 in cp_parser_function_definition_after_declarator (parser=0xb7c82c64, inline_p=0 
'\0')
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14868
#3  0x080f7645 in cp_parser_init_declarator (parser=0xb7c82c64, decl_specifiers=0xbff8c378, 
function_definition_allowed_p=1 '\001', 
    member_p=0 '\0', declares_class_or_enum=Variable "declares_class_or_enum" is not available.
) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14813
#4  0x080f7849 in cp_parser_simple_declaration (parser=0xb7c82c64, 
function_definition_allowed_p=1 '\001')
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:7007
Comment 3 wanderer 2005-03-17 22:21:29 UTC
I found time of regression.
GCC CVS mainline at 2004-07-12 16:00 GMT compile testcase without problem.
GCC CVS mainline at 2004-07-12 16:20 CMT ICE at testcase

CVS changes from http://gcc.gnu.org/ml/gcc-cvs/2004-07/ in this time range:
16:16 gcc/gcc/cp name-lookup.c nathan 
16:06 gcc/gcc/cp ChangeLog call.c class.c cvt.c decl ... nathan 
Comment 4 Andrew Pinski 2005-03-18 19:13:43 UTC
*** Bug 20536 has been marked as a duplicate of this bug. ***
Comment 5 Paolo Carlini 2005-03-18 22:16:54 UTC
Notice that the ICE happen only with checking enabled, but seems easy to fix
and we can avoid "confused by earlier errors, bailing out" otherwise.
Comment 6 Andrew Pinski 2005-03-20 17:29:51 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01879.html>.
Comment 7 GCC Commits 2005-03-21 11:49:58 UTC
Subject: Bug 20461

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2005-03-21 11:49:36

Modified files:
	gcc/cp         : ChangeLog init.c semantics.c 

Log message:
	2005-03-21  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20461
	PR c++/20536
	* init.c (emit_mem_initializers): Don't crash on undefined
	types.
	
	2005-03-21  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20147
	* semantics.c (finish_stmt_expr_expr): Return immediately
	if error_operand_p (expr).

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4669&r2=1.4670
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.414&r2=1.415
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.464&r2=1.465

Comment 8 GCC Commits 2005-03-21 11:53:14 UTC
Subject: Bug 20461

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2005-03-21 11:53:00

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: crash24.C crash25.C 
	gcc/testsuite/g++.dg/ext: stmtexpr4.C 

Log message:
	2005-03-21  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20461
	* g++.dg/parse/crash24.C: New test.
	
	PR c++/20536
	* g++.dg/parse/crash25.C: New test.
	
	2005-03-21  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20147
	* g++.dg/ext/stmtexpr4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5186&r2=1.5187
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash24.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash25.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/stmtexpr4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 Volker Reichelt 2005-03-21 12:51:21 UTC
Hi Paolo,

the testcase g++.dg/parse/crash25.C is hosed:

// PR c++/20536
// Found by Wolfgang Wieser 03/2005.
// { do-do compile }
  ^^^^^^^

This should be dg-do, right?
Could you please fix that?
Comment 10 Paolo Carlini 2005-03-21 12:52:40 UTC
Oops! Will do momentarily. Thanks.
Comment 11 GCC Commits 2005-03-22 09:11:44 UTC
Subject: Bug 20461

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	paolo@gcc.gnu.org	2005-03-22 09:11:03

Modified files:
	gcc/cp         : ChangeLog init.c parser.c 

Log message:
	2005-03-22  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20461
	PR c++/20536
	* init.c (emit_mem_initializers): Don't crash on undefined
	types.
	
	2005-03-22  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20463
	* parser.c (cp_parser_diagnose_invalid_type_name):
	Check TYPE_BINFO (current_class_type) before attempting
	to emit inform messages.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.13&r2=1.4648.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.412.2.2&r2=1.412.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.319.2.1&r2=1.319.2.2

Comment 12 GCC Commits 2005-03-22 09:28:53 UTC
Subject: Bug 20461

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	paolo@gcc.gnu.org	2005-03-22 09:28:26

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: crash24.C crash25.C 
	gcc/testsuite/g++.dg/template: crash35.C 

Log message:
	2005-03-22  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20461
	* g++.dg/parse/crash24.C: New test.
	
	PR c++/20536
	* g++.dg/parse/crash25.C: New test.
	
	2005-03-22  Paolo Carlini  <pcarlini@suse.de>
	
	PR c++/20463
	* g++.dg/template/crash35.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.57&r2=1.5084.2.58
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash24.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash25.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash35.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.4.1

Comment 13 Paolo Carlini 2005-03-22 09:30:31 UTC
Fixed for 4.0.