This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH, committed] Fix PR9457


Hi

The CONSTRUCTOR_ELTS of a CONSTRUCTOR tree node is substituted
with template arguments twice by tsubst_copy_and_build (once
at the beginning of 'for' loop, and another inside this 'for' loop).
This causes ICE when a PARM_DECL is inside CONSTRUCTOR as
the PARM_DECL case in tsubst_copy cannot deal with this.  
Fixed by the appended patch.

Tested on i686-pc-linux-gnu.  Commited to main trunk as obvious.

--Kriang


2003-02-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/9457
	* pt.c (tsubst_copy_and_build) [CONSTRUCTOR]: Substitute
	CONSTRUCTOR_ELTS only once.

2003-02-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/9457
	* g++.dg/template/init1.C: New test.


diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Sat Feb 15 01:02:29 2003
--- gcc-main-new/gcc/cp/pt.c	Mon Feb 17 20:31:05 2003
*************** tsubst_copy_and_build (t, args, complain
*** 8290,8297 ****
  	   initializers as they are identifier nodes which will be
  	   looked up by digest_init.  */
  	purpose_p = !(type && IS_AGGR_TYPE (type));
! 	for (elts = tsubst_copy (CONSTRUCTOR_ELTS (t), args, complain,
! 				 in_decl);
  	     elts;
  	     elts = TREE_CHAIN (elts))
  	  {
--- 8290,8296 ----
  	   initializers as they are identifier nodes which will be
  	   looked up by digest_init.  */
  	purpose_p = !(type && IS_AGGR_TYPE (type));
! 	for (elts = CONSTRUCTOR_ELTS (t);
  	     elts;
  	     elts = TREE_CHAIN (elts))
  	  {
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/init1.C gcc-main-new/gcc/testsuite/g++.dg/template/init1.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/init1.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/init1.C	Mon Feb 17 22:32:11 2003
***************
*** 0 ****
--- 1,10 ----
+ // { dg-do compile }
+ 
+ // Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+ 
+ // PR c++/9457: ICE tsubst'ing initializers in templates.
+ 
+ template <typename> void foo (int count) {
+   int i = {count};
+ }
+ template void foo<int> (int);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]