Re: [PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-06 Thread Jason Merrill via Gcc-patches
ild2_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, How about passing lval down here and returning mod ei

Re: [PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-05 Thread Patrick Palka via Gcc-patches
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_express

Re: [PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-05 Thread Jason Merrill via Gcc-patches
On 3/5/21 1:05 PM, Patrick Palka wrote: Here, during cxx_eval_increment_expression (with lval=false) of ++__first where __first is &"mystr"[0], we correctly update __first to &"mystr"[1] but we end up returning &"mystr"[0] + 1 instead of &"mystr"[1]. This unreduced return value inhibits other po

[PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-05 Thread Patrick Palka via Gcc-patches
Here, during cxx_eval_increment_expression (with lval=false) of ++__first where __first is &"mystr"[0], we correctly update __first to &"mystr"[1] but we end up returning &"mystr"[0] + 1 instead of &"mystr"[1]. This unreduced return value inhibits other pointer arithmetic folding during later cons