C++ PATCH for c++/55137 (dynamic initialization with overflow)

Submitted by Jason Merrill on Nov. 22, 2012, 2:40 p.m.


Message ID 50AE3944.4040708@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 22, 2012, 2:40 p.m.
In this PR, fold introduces TREE_OVERFLOW into an expression.  This 
seems wrong, and Jakub has a separate patch to address that issue, but 
it seemed to me that GCC should still do static initialization even if 
the initializer involves overflow.  So this patch adjusts the constexpr 
evaluation code to do normal folding of expressions that involve 
overflow, and just make sure that what we return doesn't have 
TREE_CONSTANT set by wrapping it in a nop.

The second patch fixes an issue revealed by the first patch: when we 
push a TARGET_EXPR into a static variable as part of extending the 
lifetime of reference temporaries, we need to recompute TREE_CONSTANT on 
the ADDR_EXPR around it.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch hide | download patch | download mbox

commit 681c0e5d2f16af2446e39acf06af936d2eddb090
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 21 16:09:03 2012 -0500

    	* call.c (extend_ref_init_temps_1): Recompute TREE_CONSTANT for
    	the ADDR_EXPR.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 35a3f91..bba5d9f 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -9188,6 +9188,7 @@  extend_ref_init_temps_1 (tree decl, tree init, vec<tree, va_gc> **cleanups)
       *p = set_up_extended_ref_temp (decl, *p, cleanups, &subinit);
       if (subinit)
 	init = build2 (COMPOUND_EXPR, TREE_TYPE (init), subinit, init);
+      recompute_tree_invariant_for_addr_expr (sub);
   return init;