OSDN Git Service

PR c++/52796
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 23:37:11 +0000 (23:37 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 23:37:11 +0000 (23:37 +0000)
* pt.c (tsubst_initializer_list): A pack expansion with no elements
means value-initialization.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186121 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic-value1.C [new file with mode: 0644]

index b8451f1..0de8e3a 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52796
+       * pt.c (tsubst_initializer_list): A pack expansion with no elements
+       means value-initialization.
+
 2012-03-29  Meador Inge  <meadori@codesourcery.com>
 
        PR c++/52672
index 56e4a9c..9834c64 100644 (file)
@@ -18983,6 +18983,7 @@ tsubst_initializer_list (tree t, tree argvec)
             }
           else
             {
+             tree tmp;
               decl = tsubst_copy (TREE_PURPOSE (t), argvec, 
                                   tf_warning_or_error, NULL_TREE);
 
@@ -18991,10 +18992,17 @@ tsubst_initializer_list (tree t, tree argvec)
                 in_base_initializer = 1;
 
              init = TREE_VALUE (t);
+             tmp = init;
              if (init != void_type_node)
                init = tsubst_expr (init, argvec,
                                    tf_warning_or_error, NULL_TREE,
                                    /*integral_constant_expression_p=*/false);
+             if (init == NULL_TREE && tmp != NULL_TREE)
+               /* If we had an initializer but it instantiated to nothing,
+                  value-initialize the object.  This will only occur when
+                  the initializer was a pack expansion where the parameter
+                  packs used in that expansion were of length zero.  */
+               init = void_type_node;
               in_base_initializer = 0;
             }
 
index d594c86..58c0157 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52796
+       * g++.dg/cpp0x/variadic-value1.C: New.
+
 2012-04-03  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-value1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-value1.C
new file mode 100644 (file)
index 0000000..179919a
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/52796
+// { dg-do run { target c++11 } }
+
+inline void *operator new(__SIZE_TYPE__ s, void *p) { return p; }
+
+struct A
+{
+  int i;
+  template<class... Ts>
+  A(Ts&&... ts): i(ts...) { }
+};
+
+static union {
+  unsigned char c[sizeof(A)];
+  int i;
+};
+
+int main()
+{
+  i = 0xdeadbeef;
+  new(c) A;
+  if (i != 0)
+    __builtin_abort();
+}