https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89149
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org, | |rguenth at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- match.pd uses here: /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)). */ (simplify (pointer_plus (pointer_plus:s @0 @1) @3) (pointer_plus @0 (plus @1 @3))) and this is invoked from #10 0x0000000001c30c8f in generic_simplify (loc=260064, code=POINTER_PLUS_EXPR, type=<pointer_type 0x7fffea820690>, op0=<pointer_plus_expr 0x7fffea94e258>, op1=<integer_cst 0x7fffea95e1c8>) at generic-match.c:52790 #11 0x0000000000f33a06 in fold_binary_loc (loc=260064, code=POINTER_PLUS_EXPR, type=<pointer_type 0x7fffea820690>, op0=<pointer_plus_expr 0x7fffea94e258>, op1=<integer_cst 0x7fffea95e1c8>) at ../../gcc/fold-const.c:9378 #12 0x0000000000f42715 in fold_build2_loc (loc=260064, code=POINTER_PLUS_EXPR, type=<pointer_type 0x7fffea820690>, op0=<pointer_plus_expr 0x7fffea94e258>, op1=<integer_cst 0x7fffea95e1c8>) at ../../gcc/fold-const.c:12350 #13 0x0000000000f49d3d in fold_build_pointer_plus_loc (loc=260064, ptr=<pointer_plus_expr 0x7fffea94e258>, off=<integer_cst 0x7fffea95e1c8>) at ../../gcc/fold-const.c:14565 #14 0x0000000000bf676b in pointer_int_sum (loc=260064, resultcode=PLUS_EXPR, ptrop=<pointer_plus_expr 0x7fffea94e258>, intop=<integer_cst 0x7fffea95e1c8>, complain=true) at ../../gcc/c-family/c-common.c:3269 #15 0x0000000000bbaf68 in cp_pointer_int_sum (loc=260064, resultcode=PLUS_EXPR, ptrop=<pointer_plus_expr 0x7fffea94e258>, intop=<integer_cst 0x7fffea8175a0>, complain=3) at ../../gcc/cp/typeck.c:5602 #16 0x0000000000bb6ea4 in cp_build_binary_op (location=..., code=PLUS_EXPR, orig_op0=<pointer_plus_expr 0x7fffea94e258>, orig_op1=<non_lvalue_expr 0x7fffea95a520>, complain=3) at ../../gcc/cp/typeck.c:4545 #17 0x0000000000bb3806 in cp_build_array_ref (loc=260064, array=<pointer_plus_expr 0x7fffea94e258>, idx=<non_lvalue_expr 0x7fffea95a520>, complain=3) at ../../gcc/cp/typeck.c:3507 Now, either we must make sure not to fold this at all for C++ before constexpr evaluation, or we'd need to defer that folding at least for the cases where the most significant bits of the two offsets are different (and both non-zero). In any case, this doesn't look like GCC9 material.