Bug 7188 - Segfault with template class and recursive (incorrect) initalizer list.
Summary: Segfault with template class and recursive (incorrect) initalizer list.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Mark Mitchell
URL:
Keywords:
: 8066 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-07-02 20:36 UTC by Nathan Sidwell
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
crash.cc (111 bytes, application/octet-stream)
2003-05-21 15:16 UTC, Nathan Sidwell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Sidwell 2002-07-02 20:36:01 UTC
If a templated class is created, the initializer list is appently not checked for recursive initialization ( my guess anyway ).  Code attached should never compile, and indead doesn't under g++ 2.95 and 3.0, however 3.1 segfaults while attempting compile.  If template declaration from top of class is removed, segfault does not occur and appropriate error message is issued.

This is not a big deal to myself, as code is clearly very wrong. However since I was silly enough to accidently write it, I imagine that it's possible someone else will do the same at some point.

Release:
3.1

Environment:
Debian w both self compiled g++ v 3.1 and from unstable, vers. 3.1.1 20020606 (Debian prerelease)

How-To-Repeat:
attempt compile of attached code under g++ 3.1
Comment 1 Nathan Sidwell 2002-07-02 20:36:01 UTC
Fix:
http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00145.html
Comment 2 Nathan Sidwell 2002-09-14 13:45:27 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: confirmed, regression
Comment 3 Mark Mitchell 2002-10-02 12:59:58 UTC
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a patch.
Comment 4 Mark Mitchell 2002-10-02 20:01:38 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7188
Date: 2 Oct 2002 20:01:38 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-02 13:01:38
 
 Modified files:
 	gcc/cp         : ChangeLog cp-tree.def cp-tree.h init.c method.c 
 	                 parse.y pt.c semantics.c 
 	gcc/testsuite  : ChangeLog 
 	gcc/testsuite/g++.old-deja/g++.mike: warn3.C 
 	gcc/testsuite/lib: prune.exp 
 Added files:
 	gcc/testsuite/g++.dg/template: meminit1.C 
 	gcc/testsuite/g++.dg/warn: Wreorder-1.C 
 
 Log message:
 	PR c++/7188.
 	* cp-tree.def (CTOR_INITIALIZER): Use one slot, not two.
 	* cp-tree.h (emit_base_init): Rename to ....
 	(emit_mem_initializers): ... this.
 	(expand_member_init): Change prototype.
 	* init.c (perform_member_init): Compute explicit, rather than
 	requiring it as a parameter.
 	(sort_member_init): Rename to ...
 	(sort_mem_initializers): ... this.  Process bases and data members
 	together.
 	(sort_base_init): Remove.
 	(emit_base_init): Rename to ...
 	(emit_mem_initializers): ... this.
 	(expand_aggr_vbase_init_1): Remove.
 	(construct_virtual_bases): Rename to ...
 	(construct_virtual_base): ... this.
 	(expand_member_init): Rework handling of base initializers.
 	* method.c (do_build_copy_constructor): Use
 	finish_mem_initializers.
 	* parse.y (member_init): Adjust calls to expand_member_init.
 	* pt.c (tsubst_expr): Simplify CTOR_INITIALIZER case.
 	(tsubst_initializer_list): Use expand_member_init.
 	* semantics.c (finish_mem_intiailizers): Simplify.
 	
 	PR c++/7188.
 	* g++.dg/template/meminit1.C: New test.
 	* g++.dg/warn/Wreorder-1.C: Likewise.
 	* g++.old-deja/g++.mike/warn3.C: Tweak.
 	* lib/prune.exp: Ingore "in copy constructor".
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.2978&r2=1.2979
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.65&r2=1.66
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.755&r2=1.756
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.293&r2=1.294
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/method.c.diff?cvsroot=gcc&r1=1.231&r2=1.232
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&r1=1.280&r2=1.281
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.619&r2=1.620
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.278&r2=1.279
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2116&r2=1.2117
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/meminit1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wreorder-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.mike/warn3.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/lib/prune.exp.diff?cvsroot=gcc&r1=1.7&r2=1.8
 

Comment 5 Mark Mitchell 2002-10-02 20:01:38 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7188
Date: 2 Oct 2002 20:01:38 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-02 13:01:38
 
 Modified files:
 	gcc/cp         : ChangeLog cp-tree.def cp-tree.h init.c method.c 
 	                 parse.y pt.c semantics.c 
 	gcc/testsuite  : ChangeLog 
 	gcc/testsuite/g++.old-deja/g++.mike: warn3.C 
 	gcc/testsuite/lib: prune.exp 
 Added files:
 	gcc/testsuite/g++.dg/template: meminit1.C 
 	gcc/testsuite/g++.dg/warn: Wreorder-1.C 
 
 Log message:
 	PR c++/7188.
 	* cp-tree.def (CTOR_INITIALIZER): Use one slot, not two.
 	* cp-tree.h (emit_base_init): Rename to ....
 	(emit_mem_initializers): ... this.
 	(expand_member_init): Change prototype.
 	* init.c (perform_member_init): Compute explicit, rather than
 	requiring it as a parameter.
 	(sort_member_init): Rename to ...
 	(sort_mem_initializers): ... this.  Process bases and data members
 	together.
 	(sort_base_init): Remove.
 	(emit_base_init): Rename to ...
 	(emit_mem_initializers): ... this.
 	(expand_aggr_vbase_init_1): Remove.
 	(construct_virtual_bases): Rename to ...
 	(construct_virtual_base): ... this.
 	(expand_member_init): Rework handling of base initializers.
 	* method.c (do_build_copy_constructor): Use
 	finish_mem_initializers.
 	* parse.y (member_init): Adjust calls to expand_member_init.
 	* pt.c (tsubst_expr): Simplify CTOR_INITIALIZER case.
 	(tsubst_initializer_list): Use expand_member_init.
 	* semantics.c (finish_mem_intiailizers): Simplify.
 	
 	PR c++/7188.
 	* g++.dg/template/meminit1.C: New test.
 	* g++.dg/warn/Wreorder-1.C: Likewise.
 	* g++.old-deja/g++.mike/warn3.C: Tweak.
 	* lib/prune.exp: Ingore "in copy constructor".
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.2978&r2=1.2979
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.65&r2=1.66
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.755&r2=1.756
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.293&r2=1.294
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/method.c.diff?cvsroot=gcc&r1=1.231&r2=1.232
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&r1=1.280&r2=1.281
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.619&r2=1.620
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.278&r2=1.279
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2116&r2=1.2117
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/meminit1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wreorder-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.mike/warn3.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/lib/prune.exp.diff?cvsroot=gcc&r1=1.7&r2=1.8
 

Comment 6 Mark Mitchell 2002-10-02 23:57:31 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in GCC 3.2.1.
Comment 7 Mark Mitchell 2002-10-03 06:55:02 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7188
Date: 3 Oct 2002 06:55:02 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-10-02 23:55:01
 
 Modified files:
 	gcc/cp         : ChangeLog init.c pt.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: meminit1.C 
 
 Log message:
 	PR c++/7188.
 	* init.c (expand_member_init): Allow a FIELD_DECL to be passed in
 	directly.
 	* pt.c (tsubst_initializer_list): Use expand_member_init.
 	
 	PR c++/7188.
 	* testsuite/g++.dg/template/meminit1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.9&r2=1.2685.2.114.2.10
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.264.2.12&r2=1.264.2.12.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.578.2.11&r2=1.578.2.11.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.18&r2=1.1672.2.166.2.19
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/meminit1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 

Comment 8 Mark Mitchell 2002-10-03 06:55:02 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7188
Date: 3 Oct 2002 06:55:02 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-10-02 23:55:01
 
 Modified files:
 	gcc/cp         : ChangeLog init.c pt.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: meminit1.C 
 
 Log message:
 	PR c++/7188.
 	* init.c (expand_member_init): Allow a FIELD_DECL to be passed in
 	directly.
 	* pt.c (tsubst_initializer_list): Use expand_member_init.
 	
 	PR c++/7188.
 	* testsuite/g++.dg/template/meminit1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.9&r2=1.2685.2.114.2.10
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.264.2.12&r2=1.264.2.12.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.578.2.11&r2=1.578.2.11.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.18&r2=1.1672.2.166.2.19
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/meminit1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1