re PR c++/56772 (placement new operator does not work inside function template for...
authorJason Merrill <jason@redhat.com>
Mon, 1 Apr 2013 21:18:23 +0000 (17:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 1 Apr 2013 21:18:23 +0000 (17:18 -0400)
PR c++/56772
* init.c (build_new): Don't try to process an array initializer
at template definition time.

From-SVN: r197326

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/g++.dg/cpp0x/initlist68.C [new file with mode: 0644]

index 7e58f704747fd28a6b41684dcbcb6e7d036efa24..6374fff4348a74ae8625b17648d0a5d3ab95ff25 100644 (file)
@@ -1,5 +1,9 @@
 2013-04-01  Jason Merrill  <jason@redhat.com>
 
+       PR c++/56772
+       * init.c (build_new): Don't try to process an array initializer
+       at template definition time.
+
        PR c++/56793
        * typeck.c (finish_class_member_access_expr): Handle enum scope.
 
index ab6af1411a6119da38c94d96a15efd5a79908911..7b7de022ee62f339cf3605a1b219282af4f0e777 100644 (file)
@@ -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 (file)
index 0000000..7cfe1a3
--- /dev/null
@@ -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<>();
+}