Bug 29022 - [4.0 regression] ICE using operator int in invalid class hierarchy
Summary: [4.0 regression] ICE using operator int in invalid class hierarchy
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 normal
Target Milestone: 4.0.4
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks: 27316 28740
  Show dependency treegraph
 
Reported: 2006-09-11 19:44 UTC by Volker Reichelt
Modified: 2006-12-03 13:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-18 19:21:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-09-11 19:44:19 UTC
The following invalid code snippet triggers a segfault since GCC 3.4.0:

==================================================
struct A
{
  operator int();
};

struct B : virtual A, A<0> {};

int foo(B &b)
{
  return b;
}
==================================================

bug.cc:6: error: expected template-name before '<' token
bug.cc:6: error: expected `{' before '<' token
bug.cc:6: error: expected unqualified-id before '<' token
bug.cc: In function 'int foo(B&)':
bug.cc:10: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-09-12 05:46:36 UTC
Backtrace:
#0  0x08106fb5 in build_vfield_ref (datum=0xb7d6d760, type=0xb7da16d4) at ../../gcc/cp/class.c:554
#1  0x081063b3 in build_base_path (code=PLUS_EXPR, expr=0xb7d6d720, binfo=0xb7ff5800, nonnull=1)
    at ../../gcc/cp/class.c:355
#2  0x0805af73 in build_over_call (cand=0x951ca24, flags=3) at ../../gcc/cp/call.c:4821
#3  0x08058bb7 in convert_like_real (convs=0x951ca80, expr=0xb7d6d6e0, fn=0x0, argnum=0, inner=0,
    issue_conversion_warnings=1 '\001', c_cast_p=0 '\0') at ../../gcc/cp/call.c:4288
#4  0x08061984 in perform_implicit_conversion (type=0xb7cfe284, expr=0xb7d6d6e0)
    at ../../gcc/cp/call.c:6431
#5  0x081a1dcc in convert_for_assignment (type=0xb7cfe284, rhs=0xb7d6d6e0,
    errtype=0x8985c65 "return", fndecl=0x0, parmnum=0) at ../../gcc/cp/typeck.c:6234
#6  0x081a228f in convert_for_initialization (exp=0x0, type=0xb7cfe284, rhs=0xb7d6d6e0, flags=11,
    errtype=0x8985c65 "return", fndecl=0x0, parmnum=0) at ../../gcc/cp/typeck.c:6323
#7  0x081a3660 in check_return_expr (retval=0xb7d6d6e0, no_warning=0xbfce47eb "")
    at ../../gcc/cp/typeck.c:6591
#8  0x081d0668 in finish_return_stmt (expr=0xb7d6d6e0) at ../../gcc/cp/semantics.c:753
Comment 2 patchapp@dberlin.org 2006-10-18 19:36:54 UTC
Subject: Bug number PR c++/29022

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/2006-10/msg00940.html
Comment 3 patchapp@dberlin.org 2006-11-18 17:30:35 UTC
Subject: Bug number PR c++/29022

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/2006-11/msg01314.html
Comment 4 Lee Millward 2006-11-29 15:19:52 UTC
Subject: Bug 29022

Author: lmillward
Date: Wed Nov 29 15:19:39 2006
New Revision: 119318

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119318
Log:
	PR c++/29022
	* parser.c (cp_parser_class_head): Move processing
	of any base classes to...
	(cp_parser_class_specifier) ...here. Take an extra
	tree* parameter for any base classes. Only process
	them if the opening brace was found.

	* g++.dg/inherit/virtual2.C: New test.
	* g++.dg/inherit/virtual3.C: Likewise.
	* g++.old-deja/g++.bugs/900121_05.C: Adjust error markers.
	* g++.dg/inherit/error2.C: Likewise.
	* g++.dg/template/instantiate1.C: Likewise.


Added:
    trunk/gcc/testsuite/g++.dg/inherit/virtual2.C
    trunk/gcc/testsuite/g++.dg/inherit/virtual3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/inherit/error2.C
    trunk/gcc/testsuite/g++.dg/template/instantiate1.C
    trunk/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C

Comment 5 Lee Millward 2006-11-29 15:20:19 UTC
Fixed on mainline.
Comment 6 Lee Millward 2006-11-29 16:51:46 UTC
Subject: Bug 29022

Author: lmillward
Date: Wed Nov 29 16:51:32 2006
New Revision: 119322

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119322
Log:
	PR c++/29022
	* parser.c (cp_parser_class_head): Move processing
	of any base classes to...
	(cp_parser_class_specifier) ...here. Take an extra
	tree* parameter for any base classes. Only process
	them if the opening brace was found.

	* g++.dg/inherit/virtual2.C: New test.
	* g++.dg/inherit/virtual3.C: Likewise.
	* g++.old-deja/g++.bugs/900121_05.C: Adjust error markers.
	* g++.dg/inherit/error2.C: Likewise.
	* g++.dg/template/instantiate1.C: Likewise.


Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/inherit/virtual2.C
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/inherit/virtual3.C
Modified:
    branches/gcc-4_2-branch/gcc/cp/ChangeLog
    branches/gcc-4_2-branch/gcc/cp/parser.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/inherit/error2.C
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/template/instantiate1.C
    branches/gcc-4_2-branch/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C

Comment 7 Lee Millward 2006-11-29 16:52:15 UTC
Fixed in 4.2.
Comment 8 Lee Millward 2006-11-29 19:02:08 UTC
Subject: Bug 29022

Author: lmillward
Date: Wed Nov 29 19:01:50 2006
New Revision: 119332

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119332
Log:
	PR c++/29022
	* parser.c (cp_parser_class_head): Move processing
	of any base classes to...
	(cp_parser_class_specifier) ...here. Take an extra
	tree* parameter for any base classes. Only process
	them if the opening brace was found.

	* g++.dg/inherit/virtual1.C: New test.
	* g++.dg/inherit/virtual2.C: Likewise.
	* g++.old-deja/g++.bugs/900121_05.C: Adjust error markers.
	* g++.dg/inherit/error2.C: Likewise.
	* g++.dg/template/instantiate1.C: Likewise.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/virtual1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/virtual2.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/parser.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/error2.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/instantiate1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C

Comment 9 Lee Millward 2006-11-29 19:02:29 UTC
Fixed in 4.1.2.
Comment 10 Lee Millward 2006-12-03 13:12:09 UTC
Subject: Bug 29022

Author: lmillward
Date: Sun Dec  3 13:11:51 2006
New Revision: 119463

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119463
Log:
	PR c++/29022
	PR c++/27316
	PR c++/28740
	* parser.c (cp_parser_class_head): Move processing
	of any base classes to...
	(cp_parser_class_specifier) ...here. Take an extra
	tree* parameter for the base classes. Only process
	them if the opening brace was found.

	PR c++/29022
	* g++.dg/inherit/virtual1.C: New test.
	* g++.dg/inherit/virtual2.C: Likewise.

	PR c++/27316
	* g++.dg/inherit/error3.C: New test.

	PR c++/28740
	* g++.dg/inherit/error4.C: New test. 


Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/error3.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/error4.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/virtual1.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/virtual2.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/parser.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/error2.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/instantiate1.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C

Comment 11 Lee Millward 2006-12-03 13:12:35 UTC
Now fixed in 4.0.4.