@@ -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);
new file mode 100644
@@ -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>()); // #
+}