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: PR 27270


This patch fixes an ICE-on-invalid regression in the handling of
compound literals in templates.  We were failing to call rehape_init
and therefore failing to detect cases in which an initializer was
incorrectly dimensionsed for the type being initialized.

Tested on x86_64-unknown-linux-gnu, applied on the mainline.  I will
apply this patch to the 4.1 branch after testing completes.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-10-16  Mark Mitchell  <mark@codesourcery.com>

	PR c++/27270
	* typeck2.c (process_init_constructor_array): Reword comment.
	* pt.c (tsubst_copy_and_built): Call reshape_init before calling
	digest_init.

2006-10-16  Mark Mitchell  <mark@codesourcery.com>

	PR c++/27270
	* g++.dg/ext/complit8.C: New test.

Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c	(revision 117789)
+++ gcc/cp/typeck2.c	(working copy)
@@ -791,8 +791,8 @@ process_init_constructor_array (tree typ
     /* Vectors are like simple fixed-size arrays.  */
     len = TYPE_VECTOR_SUBPARTS (type);
 
-  /* There cannot be more initializers than needed (or reshape_init would
-     detect this before we do.  */
+  /* There cannot be more initializers than needed as otherwise
+     reshape_init would have already rejected the initializer.  */
   if (!unbounded)
     gcc_assert (VEC_length (constructor_elt, v) <= len);
 
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 117789)
+++ gcc/cp/pt.c	(working copy)
@@ -9351,7 +9351,10 @@ tsubst_copy_and_build (tree t,
 	TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t);
 
 	if (type)
-	  return digest_init (type, r);
+	  {
+	    r = reshape_init (type, r);
+	    return digest_init (type, r);
+	  }
 	return r;
       }
 
Index: gcc/testsuite/g++.dg/ext/complit8.C
===================================================================
--- gcc/testsuite/g++.dg/ext/complit8.C	(revision 0)
+++ gcc/testsuite/g++.dg/ext/complit8.C	(revision 0)
@@ -0,0 +1,12 @@
+// PR c++/27270
+// { dg-options "" }
+
+template<typename Entry>
+struct Array {
+  Entry *array[32];
+  Array () :
+    array ( (Entry*[1]) { 0, 0 } ) // { dg-error "initializers|conversion" }
+  {}
+};
+
+Array<void*> a;


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