Patchwork C++ PATCH for c++/56772 (array new with initializer-list)

login
register
mail settings
Submitter Jason Merrill
Date April 1, 2013, 9:17 p.m.
Message ID <5159F953.9030603@redhat.com>
Download mbox | patch
Permalink /patch/232810/
State New
Headers show

Comments

Jason Merrill - April 1, 2013, 9:17 p.m.
Here trying to process the initializer at template time didn't work; 
let's not bother in this case.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.

Patch

commit 48ec5c5cc4c8f5640dd25b3b455141cde868361c
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Apr 1 16:30:48 2013 -0400

    	PR c++/56772
    	* init.c (build_new): Don't try to process an array initializer
    	at template definition time.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index ab6af14..7b7de02 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2920,6 +2920,7 @@  build_new (vec<tree, va_gc> **placement, tree type, tree nelts,
       if (dependent_type_p (type)
 	  || any_type_dependent_arguments_p (*placement)
 	  || (nelts && type_dependent_expression_p (nelts))
+	  || (nelts && *init)
 	  || any_type_dependent_arguments_p (*init))
 	return build_raw_new_expr (*placement, type, nelts, *init,
 				   use_global_new);
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist68.C b/gcc/testsuite/g++.dg/cpp0x/initlist68.C
new file mode 100644
index 0000000..7cfe1a3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist68.C
@@ -0,0 +1,20 @@ 
+// PR c++/56772
+// { dg-require-effective-target c++11 }
+
+typedef __SIZE_TYPE__ size_t;
+void* operator new[](size_t, void *p) { return p; }
+template <typename T = size_t>
+void f ()
+{
+  size_t coord [2][2];
+  new (&coord) size_t [2][2]
+   {
+     {0,0},
+     {0,0},
+   };
+}
+
+int main ()
+{
+   f<>();
+}