https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99287
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- IIUC, those two types are actually the same, it's just that one of them was obtained through the char_type alias, and it seems debug_tree prefers to show the name of the alias when the type came from one. It seems the issue ultimately is in cxx_eval_increment_expression: during evaluation of ++__first with __first = &"mystr"[n] + m and with lval=false, since cxx_fold_pointer_plus_expression and not fold_build2 is responsible for simplifying this POINTER_PLUS_EXPR to &"mystr"[n+m], returning 'mod' actually returns the unreduced &"mystr"[n] + m rather than the reduced &"mystr"[n+m] that we obtain as part of constexpr evaluation of the temporary MODIFY_EXPR. This unreduced return value of cxx_eval_increment interfers with later constexpr evaluation, e.g. folding of the POINTER_DIFF_EXPR. I'm testing the following which updates 'mod' with the result of evaluation of the MODIFY_EXPR: --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5582,20 +5582,14 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t, /* Storing the modified value. */ tree store = build2_loc (cp_expr_loc_or_loc (t, input_location), MODIFY_EXPR, type, op, mod); - cxx_eval_constant_expression (ctx, store, - true, non_constant_p, overflow_p); + mod = cxx_eval_constant_expression (ctx, store, false, + non_constant_p, overflow_p); ggc_free (store); /* And the value of the expression. */