Consider the following pseudocode (language agnostic):
int f(reference int y) {
y++;
return 2;
}
int v = 1;
v += f(v);
When the function f
changes y
(that is v
) while evaluating v += f(v)
, is the original value of v
"frozen" and changes to v
"lost"?
v += f(v); // Compute the address of v (l-value)
// Evaluate v (1)
// Execute f(v), which returns 2
// Store 1 + 2
printf(v); // 3