S
Stephen Sprunk
The key is to notice that the sequence points establish that
10 is before x = 1 is before 30 and that
20 is before x = 2 is before 40
but that there is NO sequence points between the first set and the
second, and no rule to prevent interleaving, so on possible execution
sequence is:
10, 20; x=1, x=2; 30, 40
where here , separates items without a sequence point, and the ; mark
sequence points. Thus the x=1 and the x=2 are not separated by a
sequence point.
Ah. I had assumed that the unspecified ordering between (10,x=1,30) and
(20,x=2,40) meant that one had to be evaluated and then the other, i.e.
they couldn't be interleaved like you show, even if we don't know which
of the two will be evaluated first.
Again, the points could occur in the order:
Sequence point before calling set_x(1)
Sequence point before calling set_x(2)
calling set_x(1) and set_x(2)
Sequence point after calling set_x(1)
Sequence point after calling set_x(2)
You need some further specification to make sure that the functions
don't overlap in execution.
Similarly, I had assumed that evaluating either function, including its
sequence points, was indivisible. In fact, I thought that was the
entire purpose of specifying there were sequence points before/after a
function call!
(All of the above being subject to the as-if rule, of course.)
S