Assignment statements are not limited to a single variable. Among other things, you can assign to elements of an array.
Consider this example of nested assignment:
int a[] = {100, 200};
a[a[1]] = a[1] = 0;
if you evaluate the sequence of assignments, it should work as follows:
a[1] = 0
After this assignment, a
looks like this: {100, 0}
a[a[1]] = 0
Knowing that a[1]
is zero, this is the same as a[0] = 0
, so the array should look like this: {0, 0}
However, the problem is that you are now banking on the fact that the side effect of a[1] = 0
is complete by the time you get to the next assignment: otherwise, you are assigning zero to a[100]
, which is way past the end of the array.
Since the order of completion of side effects is not defined in the absence of sequence points, this is undefined behavior.