Does this code in C fall into the Undefined Behavior category?
问题 a is an array, foo is a function, and i is an int . a[++i] = foo(a[i-1], a[i]); Would the code above, have an Undefined Behavior ? The array indices ++i , i-1 and i , are guaranteed to be in the array range. 回答1: The behavior is undefined, but it's not because of the modification of the same object twice between two sequence points but it is UB because the side effect on i is unsequnced relative to the value computation of a[i-1] and a[i] using i . §6.5-p(2): If a side effect on a scalar