From: Jason Merrill Date: Thu, 5 May 2011 14:53:35 +0000 (-0400) Subject: re PR c++/48873 ([C++0x][noexcept] Placement-new problem with deleted destructors) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3edeff4e165c874cac9c59f243fd7c0cec0dd93;p=gcc.git re PR c++/48873 ([C++0x][noexcept] Placement-new problem with deleted destructors) PR c++/48873 * tree.c (stabilize_expr): Don't make gratuitous copies of classes. From-SVN: r173433 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 856e8c762b4..ff3ad54d05f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-05-05 Jason Merrill + + PR c++/48873 + * tree.c (stabilize_expr): Don't make gratuitous copies of classes. + 2011-05-05 Eric Botcazou * decl.c (start_preparsed_function): Do not set diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0f2f86cd4b4..9a6e26dcabf 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3119,7 +3119,10 @@ stabilize_expr (tree exp, tree* initp) if (!TREE_SIDE_EFFECTS (exp)) init_expr = NULL_TREE; - else if (!TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp)) + /* There are no expressions with REFERENCE_TYPE, but there can be call + arguments with such a type; just treat it as a pointer. */ + else if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE + || SCALAR_TYPE_P (exp) || !lvalue_or_rvalue_with_address_p (exp)) { init_expr = get_target_expr (exp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8c8d60b30c..15e40388217 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-05-05 Jason Merrill + + * g++.dg/init/new32.C: New. + 2011-05-05 Rainer Orth * gfortran.dg/fmt_g0_6.f08: Use dg-options "-ffloat-store". diff --git a/gcc/testsuite/g++.dg/init/new32.C b/gcc/testsuite/g++.dg/init/new32.C new file mode 100644 index 00000000000..f82785749ce --- /dev/null +++ b/gcc/testsuite/g++.dg/init/new32.C @@ -0,0 +1,16 @@ +// PR c++/48873 + +#include + +struct D { +private: + ~D(); +}; + +template +T& create(); + +void f() +{ + D* dp = new (((void*) 0)) D(create()); // # +}