Comments
Patch
@@ -3058,9 +3058,7 @@ stabilize_expr (tree exp, tree* initp)
if (!TREE_SIDE_EFFECTS (exp))
init_expr = NULL_TREE;
- /* 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
+ else if (!TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp))
|| !lvalue_or_rvalue_with_address_p (exp))
{
init_expr = get_target_expr (exp);
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/47003
+
+struct A
+{
+ A(int);
+};
+
+volatile int i;
+
+int main()
+{
+ A *q = new A (i);
+}
My earlier change to stabilize_expr was just wrong; if a type doesn't need to be created by a constructor, we want to save its value, not the glvalue that designates its address. This patch restores the previous use of TYPE_NEEDS_CONSTRUCTING, while leaving alone the actual xvalue changes. Tested x86_64-pc-linux-gnu, applied to trunk. commit 2b226072923eef3ee84d04d3a60f4cdb7657e3bd Author: Jason Merrill <jason@redhat.com> Date: Mon Dec 20 14:07:49 2010 -0500 PR c++/47003 * tree.c (stabilize_expr): Really stabilize scalar glvalues.