]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/48873 ([C++0x][noexcept] Placement-new problem with deleted destructors)
authorJason Merrill <jason@redhat.com>
Fri, 20 May 2011 20:01:42 +0000 (16:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 20 May 2011 20:01:42 +0000 (16:01 -0400)
PR c++/48873
* tree.c (stabilize_expr): Don't make gratuitous copies of classes.

From-SVN: r173979

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

index 3f0c0757806250f29c66171e081e8af2cb4d6ac7..5184bc050182a94e871395053c8312fdafcf36cc 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/48873
+       * tree.c (stabilize_expr): Don't make gratuitous copies of classes.
+
 2009-02-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR c++/39219
index 47daad77144481e680600a9463d61348982a78cf..70cf67d7fe7980a93b4b2e20b6b4c5bebcc95f1b 100644 (file)
@@ -2579,7 +2579,8 @@ stabilize_expr (tree exp, tree* initp)
   if (!TREE_SIDE_EFFECTS (exp))
     init_expr = NULL_TREE;
   else if (!real_lvalue_p (exp)
-          || !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp)))
+          || (!TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp))
+              && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (exp))))
     {
       init_expr = get_target_expr (exp);
       exp = TARGET_EXPR_SLOT (init_expr);
index c46107d675f521cf1f785102dc43909abe972c53..a4dffe2b1a7dc3fa18b286f0b18796c571f7d6cf 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-20  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/init/new32.C: New.
+
 2011-05-14  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/init/new32.C b/gcc/testsuite/g++.dg/init/new32.C
new file mode 100644 (file)
index 0000000..f827857
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/48873
+
+#include <new>
+
+struct D {
+private:
+  ~D();
+};
+
+template<class T>
+T& create();
+
+void f()
+{
+  D* dp = new (((void*) 0)) D(create<D>()); // #
+}