https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105440
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Seems this is ultimately an FE bug which is fixed by:
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index d1097764b10..9dbbf6eec03 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -3213,7 +3213,12 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree
t,
&& CLASS_TYPE_P (TREE_TYPE (res))
&& !is_empty_class (TREE_TYPE (res)))
if (replace_decl (&result, res, ctx->object))
- cacheable = false;
+ {
+ cacheable = false;
+ result = cxx_eval_constant_expression (ctx, result, lval,
+ non_constant_p,
+ overflow_p);
+ }
}
else
/* Couldn't get a function copy to evaluate. */
In some cases we can simplify a call result further after replacing RESULT_DECL
with the current object under construction throughout the call result, which
allows fold_binary_loc etc to later successfully fold comparisons involving the
call result such as _M_data() == _M_local_data() in this case.