Bug 11525 - [3.4 Regression] ICE/segfault on C++ code
Summary: [3.4 Regression] ICE/segfault on C++ code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Nathan Sidwell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-15 08:47 UTC by Markus Werle
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host: hppa2.0w-hp-hpux11.11
Target: *-*-*
Build: hppa2.0w-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed: 2003-07-15 14:47:12


Attachments
the input file that triggers the crash (186.49 KB, text/plain)
2003-07-15 09:11 UTC, Markus Werle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Werle 2003-07-15 08:47:47 UTC
Hi!

Since it seems the crash appears at a rather normal place
in the code (no ET magic or so) I have no idea what might have gone wrong,
sorry.

Configured with: ../gcc/configure --prefix=/opt/FREE-SOFTWARE/gcc-20030715
--with-gnu-as --with-as=/opt/FREE-SOFTWARE/binutils-2.14/bin/as
--with-out-gnu-ld --enable-languages=c,c++
--enable-version-specific-runtime-libs --disable-multilib
Thread model: single
gcc version 3.4 20030715 (experimental)

I attach the .ii file in a minute (why is this button missing in this form?)

Mrkus
Comment 1 Markus Werle 2003-07-15 09:11:02 UTC
Created attachment 4406 [details]
the input file that triggers the crash
Comment 2 Andrew Pinski 2003-07-15 11:25:43 UTC
I can reproduce it on powerpc-apple-darwin6.6 with the backtrace:
#0  convert_from_reference (val=0x282cf00) at /Volumes/UFS_Partition/pinskia/src/fsf/
gcc-clean/src/gcc/cp/cvt.c:570
#1  0x00037eb0 in tsubst_copy_and_build (t=0x282cf00, args=0x0, complain=tf_error, 
in_decl=0x0, function_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/
gcc/cp/pt.c:8358
#2  0x0003826c in tsubst_copy_and_build (t=0x282cf00, args=0x0, complain=tf_error, 
in_decl=0x0, function_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/
gcc/cp/pt.c:8068
#3  0x00068bd4 in cp_parser_fold_non_dependent_expr.473 (expr=0x282cf00) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:13852
#4  0x0006491c in cp_parser_direct_declarator.495 (parser=0x282cf00, dcl_kind=
CP_PARSER_DECLARATOR_NAMED, ctor_dtor_or_conv_p=0x0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:9696
#5  0x00064444 in cp_parser_declarator.428 (parser=0x480000, dcl_kind=42127104, 
ctor_dtor_or_conv_p=0x0) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/parser.c:9490
#6  0x00063f70 in cp_parser_init_declarator.449 (parser=0x2, decl_specifiers=0x0, 
prefix_attributes=0x451744, function_definition_allowed_p=true, member_p=false, 
function_definition_p=0x0) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/parser.c:9172
#7  0x00060aa0 in cp_parser_simple_declaration.434 (parser=0x282cf00, 
function_definition_allowed_p=4718592) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-
clean/src/gcc/cp/parser.c:6109
#8  0x0006096c in cp_parser_block_declaration.435 (parser=0x282cf00, statement_p=
4718592) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:6035
#9  0x000604c0 in cp_parser_declaration_statement.423 (parser=0x282cf00) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5754
#10 0x0005f9f8 in cp_parser_statement.417 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5176
#11 0x0005fdb0 in cp_parser_statement_seq_opt.425 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5327
#12 0x0005fd44 in cp_parser_compound_statement.343 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5300
#13 0x0006053c in cp_parser_implicitly_scoped_statement.427 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5788
#14 0x0005ff70 in cp_parser_selection_statement.419 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5398
#15 0x0005fb48 in cp_parser_statement.417 (parser=0x2996120) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5128
#16 0x0005fdb0 in cp_parser_statement_seq_opt.425 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5327
#17 0x0005fd44 in cp_parser_compound_statement.343 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5300
#18 0x0005fb34 in cp_parser_statement.417 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5164
#19 0x000602a8 in cp_parser_iteration_statement.420 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5612
#20 0x0005fb54 in cp_parser_statement.417 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5134
#21 0x0005fdb0 in cp_parser_statement_seq_opt.425 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5327
#22 0x0005fd44 in cp_parser_compound_statement.343 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5300
#23 0x0005fb34 in cp_parser_statement.417 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5164
#24 0x000602a8 in cp_parser_iteration_statement.420 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5612
#25 0x0005fb54 in cp_parser_statement.417 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5134
#26 0x0005fdb0 in cp_parser_statement_seq_opt.425 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5327
#27 0x0005fd44 in cp_parser_compound_statement.343 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5300
#28 0x0006053c in cp_parser_implicitly_scoped_statement.427 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5788
#29 0x0005ff70 in cp_parser_selection_statement.419 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5398
#30 0x0005fb48 in cp_parser_statement.417 (parser=0x2981f00) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5128
#31 0x0005fdb0 in cp_parser_statement_seq_opt.425 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5327
#32 0x0005fd44 in cp_parser_compound_statement.343 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5300
#33 0x00065664 in cp_parser_ctor_initializer_opt_and_function_body.505 (parser=
0x141cb60) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/
parser.c:10713
#34 0x000681f4 in cp_parser_function_definition_after_declarator.526 (parser=
0x141cb60, inline_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/parser.c:13390
#35 0x00068134 in cp_parser_function_definition_from_specifiers_and_declarator.490 
(parser=0x141cb60, decl_specifiers=0x0, attributes=0x1, declarator=0x0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:13336
#36 0x000655cc in cp_parser_function_definition.501 (parser=0x141cb60, friend_p=
0xbffff648) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:10682
#37 0x0006864c in cp_parser_single_declaration.474 (parser=0x141cb60, member_p=
false, friend_p=0xbffff648) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/
parser.c:13564
#38 0x00068328 in cp_parser_template_declaration_after_export.462 (parser=
0x141cb60, member_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/
gcc/cp/parser.c:13450
#39 0x00068440 in cp_parser_template_declaration_after_export.462 (parser=
0x141cb60, member_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/
gcc/cp/parser.c:13447
#40 0x0006087c in cp_parser_declaration.436 (parser=0x0) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5931
#41 0x00060664 in cp_parser_declaration_seq_opt.340 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5864
#42 0x00063838 in cp_parser_namespace_definition.441 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:8787
#43 0x00060888 in cp_parser_declaration.436 (parser=0x141cb60) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5950
#44 0x00060664 in cp_parser_declaration_seq_opt.340 (parser=0x141cb60) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5864
#45 0x0005cac8 in cp_parser_translation_unit.339 (parser=0x4516b0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:2141
#46 0x0006942c in c_parse_file () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/
src/gcc/cp/parser.c:14277
#47 0x000b369c in c_common_parse_file (set_yydebug=42127104) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/c-opts.c:1216
#48 0x000cc3c4 in compile_file.307 () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-
clean/src/gcc/toplev.c:1930
#49 0x000d17fc in do_compile.353 () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-
clean/src/gcc/toplev.c:4771
#50 0x000d1930 in toplev_main (argc=12, argv=0xbffffbdc) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc-clean/src/gcc/toplev.c:4812
#51 0x00002178 in _start (argc=12, argv=0xbffffbdc, envp=0xbffffbdc) at /SourceCache/
Csu/Csu-45/crt.c:267
Looks to be target independent.
I do not have time right now to reduce it.
Comment 3 Wolfgang Bangerth 2003-07-15 14:47:11 UTC
OK, this is as small sas I can get it:
------------------------------------
template <typename> class X;

template<class T>
void foo() {
  const unsigned int j = T().begin()->first;
  X<int> v;
  v[j].push_back(0);
}
-------------------------------------
With tonight's compiler, I get
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc
x.cc: In function `void foo()':
x.cc:7: internal compiler error: Segmentation fault
Please submit a full bug report,

Note that this happens during template parsing time, not during 
instantiation. I guess the code as is is illegal (since X is not
defined at the point of use, but the original code looked definitely
legal).

W.
Comment 4 Andrew Pinski 2003-07-15 14:53:04 UTC
With the small test case and with Phil's regression hunter: Search converges between 2003-07-08-
trunk (#330) and 2003-07-09-trunk (#331).
Comment 5 GCC Commits 2003-08-01 09:10:34 UTC
Subject: Bug 11525

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2003-08-01 09:10:29

Modified files:
	gcc/cp         : parser.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: constant4.C 

Log message:
	cp:
	PR c++/11525
	* parser.c (cp_parser_primary_expression): Do not set
	non-constant-p merely because it is a dependent scope.
	testsuite:
	PR c++/11525
	* g++.dg/parse/constant4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.93&r2=1.94
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3574&r2=1.3575
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2939&r2=1.2940
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/constant4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 Nathan Sidwell 2003-08-01 09:16:06 UTC
	PR c++/11525
	* parser.c (cp_parser_primary_expression): Do not set
	non-constant-p merely because it is a dependent scope.