static tree
decl_constant_value_for_broken_optimization (tree decl)
{
+ tree ret;
+
if (pedantic || DECL_MODE (decl) == BLKmode)
return decl;
- else
- return decl_constant_value (decl);
+
+ ret = decl_constant_value (decl);
+ /* Avoid unwanted tree sharing between the initializer and current
+ function's body where the tree can be modified e.g. by the
+ gimplifier. */
+ if (ret != decl && TREE_STATIC (decl))
+ ret = unshare_expr (ret);
+ return ret;
}