Bug 7931 - [Regression] The compiler ices on some legal code
Summary: [Regression] The compiler ices on some legal code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: ---
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2002-09-16 10:16 UTC by Theodore.Papadopoulo
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
MemberRef.C (228 bytes, text/x-c++ )
2003-05-21 15:16 UTC, Theodore.Papadopoulo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Theodore.Papadopoulo 2002-09-16 10:16:01 UTC
The current CVS sources (but this is true for at least 3 weeks) cannot compile the following small piece of code.
This is a regression from 3.2.

hawai->/usr/local/gcc-3.2/bin/g++ -c toto.C
hawai->g++ toto.C
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
hawai->g++ -v
Reading specs from /proj/odyssee/home/gnu/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../../Cvs/gcc/gcc-mainline/configure --with-gnu-as --with-gnu-ld --with-as=/proj/odyssee/home/gnu/binutils/bin/as --with-ld=/proj/odyssee/home/gnu/binutils/bin/ld --prefix=/proj/odyssee/home/gnu/gcc --enable-runpath
Thread model: posix
gcc version 3.3 20020910 (experimental)
hawai->/proj/odyssee/home/gnu/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus toto.C
 R::R() R::R() R::R() H::H() H::H() H::H() double& H::f() double H::f() constSegmentation fault

From gdb, it looks like the compiler is entering in an infinite loop over an error_mark_node:

This GDB was configured as "i686-pc-linux-gnu"...
(gdb) run toto.C
Starting program: /0/proj/odyssee/home/gnu/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus toto.C
 R::R() R::R() R::R() H::H() H::H() H::H() double& H::f() double H::f() const
Program received signal SIGSEGV, Segmentation fault.
0x0808f5c5 in for_each_template_parm_r (tp=0x4014bd80, walk_subtrees=0xbf800028, d=0xbfffe950)
    at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:4340
4340    {
(gdb) bt
#0  0x0808f5c5 in for_each_template_parm_r (tp=0x4014bd80, walk_subtrees=0xbf800028, d=0xbfffe950)
    at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:4340
#1  0x0831f114 in walk_tree (tp=0x4014bd94, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1434
#2  0x0831f26f in walk_tree (tp=0x401511a0, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#3  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#4  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#5  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#6  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#7  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#8  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#9  0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#10 0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#11 0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
#12 0x0831f26f in walk_tree (tp=0x4014bd90, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)


The bottom of the stack is:

#174654 0x400319cb in __libc_start_main (main=0x814a1a0 <main>, argc=2, argv=0xbffff6c4, init=0x80490cc <_init>, 
    fini=0x83bc490 <_fini>, rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffff6bc) at ../sysdeps/generic/libc-start.c:92
92      ../sysdeps/generic/libc-start.c: No such file or directory.
        in ../sysdeps/generic/libc-start.c
(gdb) down
#174653 0x0814a1bb in main (argc=-1073747632, argv=0xbfffe950) at ../../../Cvs/gcc/gcc-mainline/gcc/main.c:35
35        return toplev_main (argc, argv);
(gdb) 
#174652 0x0830dc5d in toplev_main (argc=-1073747632, argv=0xbffff600) at ../../../Cvs/gcc/gcc-mainline/gcc/toplev.c:5365
5365        do_compile ();
(gdb) 
#174651 0x0830dbb5 in do_compile () at ../../../Cvs/gcc/gcc-mainline/gcc/toplev.c:5335
5335        compile_file ();
(gdb) 
#174650 0x08307fed in compile_file () at ../../../Cvs/gcc/gcc-mainline/gcc/toplev.c:2130
2130      (*lang_hooks.parse_file) (set_yydebug);
(gdb) 
#174649 0x08140da9 in c_common_parse_file (set_yydebug=-1073747632) at ../../../Cvs/gcc/gcc-mainline/gcc/c-lex.c:159
159       yyparse ();
(gdb) 
#174648 0x080da944 in yyparse () at parse.y:1109
1109    parse.y: No such file or directory.
        in parse.y
(gdb) 
#174647 0x08115e17 in finish_template_type (name=0xbfffe950, args=0xbfffe950, entering_scope=-1073747632)
    at ../../../Cvs/gcc/gcc-mainline/gcc/cp/semantics.c:2036
2036      decl = lookup_template_class (name, args,
(gdb) 
#174646 0x0808e012 in lookup_template_class (d1=0x40139ac8, arglist=0x40151e9c, in_decl=0x0, context=0x0, entering_scope=0, 
    complain=tf_error) at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:4096
4096              = coerce_template_parms (INNERMOST_TEMPLATE_PARMS (parmlist),
(gdb) 
#174645 0x0808be0f in coerce_template_parms (parms=0x4011d880, args=0x40139ab4, in_decl=0x40148a80, complain=tf_error, 
    require_all_arguments=1) at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:3599
3599            arg = convert_template_argument (TREE_VALUE (parm), 
(gdb) 
#174644 0x0808b7c0 in convert_template_argument (parm=0x40148850, arg=0x40151eec, args=0x4015b0c0, complain=tf_error, i=1, 
    in_decl=0x40148a80) at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:3482
3482          if (!uses_template_parms (arg) && !uses_template_parms (t))
(gdb) 
#174643 0x0808fe21 in uses_template_parms (t=0xbfffe950) at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:4514
4514      return for_each_template_parm (t, 0, 0);
(gdb) 
#174642 0x0808fdf4 in for_each_template_parm (t=0x40151eec, fn=0xbfffe950, data=0xbfffe950)
    at ../../../Cvs/gcc/gcc-mainline/gcc/cp/pt.c:4504
4504      return walk_tree (&t, 
(gdb) 
#174641 0x0831f72e in walk_tree (tp=0xbfffe960, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1486
1486            WALK_SUBTREE (TREE_OPERAND (*tp, i));
(gdb) 
#174640 0x0831f72e in walk_tree (tp=0x40151efc, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1486
1486            WALK_SUBTREE (TREE_OPERAND (*tp, i));
(gdb) 
#174639 0x0831f72e in walk_tree (tp=0x4015b0b4, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1486
1486            WALK_SUBTREE (TREE_OPERAND (*tp, i));
(gdb) 
#174638 0x0831f26f in walk_tree (tp=0x4015b090, func=0x808f5c0 <for_each_template_parm_r>, data=0xbfffe950, htab_=0x0)
    at ../../../Cvs/gcc/gcc-mainline/gcc/tree-inline.c:1567
1567              WALK_SUBTREE (TREE_VEC_ELT (*tp, len));

Release:
cvs gcc version 3.3 20020910 (but exists for more than 3 weeks).

Environment:
i686-pc-linux-gnu

How-To-Repeat:
Just compile the previous file.
Comment 1 Theodore.Papadopoulo 2002-09-16 10:16:01 UTC
Fix:
http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00214.html
Comment 2 Kriang Lerdsuwanakij 2002-09-28 07:25:17 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.  A regression from GCC 3.2.
Comment 3 Mark Mitchell 2002-10-03 00:06:09 UTC
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a fix.
Comment 4 Mark Mitchell 2002-10-03 22:15:05 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in G++ 3.3.
Comment 5 Mark Mitchell 2002-10-04 05:13:59 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7931
Date: 4 Oct 2002 05:13:59 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-03 22:13:59
 
 Modified files:
 	gcc/cp         : ChangeLog decl2.c pt.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: ptrmem3.C union1.C 
 
 Log message:
 	PR c++/7931
 	* pt.c (for_each_template_parm_r): Handle BASELINKs.
 	
 	PR c++/7754
 	* decl2.c (finish_anon_union): Do not expand anonymous unions when
 	procesing template functions.
 	* pt.c (tsubst_decl, case VAR_DECL): Try to complete the variable
 	type. Call layout_decl.
 	(tsubst_expr, case DECL_STMT): Handle anonymous unions.
 	
 	PR c++/7931
 	* g++.dg/template/ptrmem3.C: New test.
 	
 	PR c++/7754
 	* g++.dg/template/union1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.2981&r2=1.2982
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.563&r2=1.564
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.620&r2=1.621
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2118&r2=1.2119
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/union1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 6 Mark Mitchell 2002-10-04 05:13:59 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7931
Date: 4 Oct 2002 05:13:59 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-03 22:13:59
 
 Modified files:
 	gcc/cp         : ChangeLog decl2.c pt.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: ptrmem3.C union1.C 
 
 Log message:
 	PR c++/7931
 	* pt.c (for_each_template_parm_r): Handle BASELINKs.
 	
 	PR c++/7754
 	* decl2.c (finish_anon_union): Do not expand anonymous unions when
 	procesing template functions.
 	* pt.c (tsubst_decl, case VAR_DECL): Try to complete the variable
 	type. Call layout_decl.
 	(tsubst_expr, case DECL_STMT): Handle anonymous unions.
 	
 	PR c++/7931
 	* g++.dg/template/ptrmem3.C: New test.
 	
 	PR c++/7754
 	* g++.dg/template/union1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.2981&r2=1.2982
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.563&r2=1.564
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.620&r2=1.621
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2118&r2=1.2119
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/union1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1