]> 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:19 +0000 (16:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 20 May 2011 20:01:19 +0000 (16:01 -0400)
PR c++/48873
* tree.c (stabilize_expr): Don't make gratuitous copies of classes.

From-SVN: r173978

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

index a85d3b1f5cbb03843f228e6c97f74351afe11b86..2549c727f2cf9831f1e96fe442c0fc76d40929fd 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.
+
 2011-05-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/48936
index ec069b0ca2169ac9b7ea623fbcb221ed8b8a25cb..dcf9872d346a660572b1fb8e38bae15b81164e34 100644 (file)
@@ -2663,7 +2663,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 3c2d721ac0d3b7ffa173c2c86c65b49e2dbf0183..1623a974f2ad0d810ec82473dcc4cb31e06d876c 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>()); // #
+}