/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Oct 2012 14:03:32 +0000 (14:03 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Oct 2012 14:03:32 +0000 (14:03 +0000)
2012-10-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/54984
* init.c (build_new): Don't turn a null *init into a pointer to
empty vector orig_init.

/testsuite
2012-10-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/54984
* g++.dg/template/new11.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192846 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 3cd3b27..1a94fb3 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/54984
+       * init.c (build_new): Don't turn a null *init into a pointer to
+       empty vector orig_init.
+
 2012-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53761
index 0446038..013b01e 100644 (file)
@@ -2911,7 +2911,8 @@ build_new (VEC(tree,gc) **placement, tree type, tree nelts,
 
       orig_placement = make_tree_vector_copy (*placement);
       orig_nelts = nelts;
-      orig_init = make_tree_vector_copy (*init);
+      if (*init)
+       orig_init = make_tree_vector_copy (*init);
 
       make_args_non_dependent (*placement);
       if (nelts)
index c3badec..75cbf7b 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/54984
+       * g++.dg/template/new11.C: New.
+
 2012-10-26  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/54824
diff --git a/gcc/testsuite/g++.dg/template/new11.C b/gcc/testsuite/g++.dg/template/new11.C
new file mode 100644 (file)
index 0000000..76f6c66
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/54984
+// { dg-do run }
+
+int n = 1;
+
+void* operator new(__SIZE_TYPE__)
+{
+  n = -1;
+  return &n;
+}
+
+template <class T>
+struct Foo
+{
+  Foo()
+  : x(new int)
+  {
+    if (*x != -1)
+      __builtin_abort();
+  }
+
+  int* x;
+};
+
+int main()
+{
+  Foo<float> foo;
+}