https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119466
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And I guess it is solely if the RHS is a CALL_EXPR, if I change the testcase to
int
foo (int &x, int *&y)
{
y = &x;
x++;
return x;
}
int
main ()
{
int a = 4;
int b = 9;
int *c = &b;
*c = foo (a, c) + 1;
__builtin_printf ("%d %d %d\n", a, *c, b);
}
(added " + 1"), then it works fine, prints 6 6 9.
Now, if there INDIRECT_REF/MEM_REF/ARRAY_REF with non-constant index, perhaps
it is fine as is, just the presence of those might mean if op1 is CALL_EXPR we
need to preevaluate op1. Unsure about exact rules though.