If cxx_eval_outermost_constant_expr doesn't change the argument, we really
shouldn't unshare it when we try to fold it again.
PR c++/92852
* constexpr.c (maybe_constant_value): Don't unshare if the cached
value is the same as the argument.
2020-02-08 Jason Merrill <jason@redhat.com>
+ PR c++/92852
+ * constexpr.c (maybe_constant_value): Don't unshare if the cached
+ value is the same as the argument.
+
* typeck.c (maybe_warn_about_returning_address_of_local): Add
location parameter.
if (cv_cache == NULL)
cv_cache = hash_map<tree, tree>::create_ggc (101);
if (tree *cached = cv_cache->get (t))
- return unshare_expr_without_location (*cached);
+ {
+ r = *cached;
+ if (r != t)
+ {
+ r = unshare_expr_without_location (r);
+ protected_set_expr_location (r, EXPR_LOCATION (t));
+ }
+ return r;
+ }
r = cxx_eval_outermost_constant_expr (t, true, true, false, false, decl);
gcc_checking_assert (r == t