https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77553
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2016-09-10 CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org Target Milestone|--- |6.3 Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The bug is that for POINTER_PLUS_EXPR we do: case POINTER_PLUS_EXPR: r = cxx_eval_pointer_plus_expression (ctx, t, lval, non_constant_p, overflow_p); if (r) break; /* fall through */ ... r = cxx_eval_binary_expression (ctx, t, lval, non_constant_p, overflow_p); break; where both cxx_eval_pointer_plus_expression and cxx_eval_binary_expression calls cxx_eval_constant_expression on both operands of the POINTER_PLUS_EXPR. That unfortunately means if the first one returns NULL_TREE, the side-effects in the two subexpressions happen multiple times. So, either we should remove cxx_eval_pointer_plus_expression and fold what it does into cxx_eval_binary_expression, or cxx_eval_pointer_plus_expression should copy what cxx_eval_binary_expression does, or add some helper function which will be called only after both operands are processed through cxx_eval_constant_expression.