It is important to note that sequence points are not global, but rather should be considered as a set of local constraints. For example, in a statement
a = f1 (x ++) + f2 (y ++);
There is a sequence point between evaluating x ++ and calling f1 and another point of sequence between evaluating y ++ and calling f2. However, there is no guarantee as to whether x will increase before or after calling f2, and whether y will increase before or after calling x. If f1 changes y or f2, change x, the results will be undefined (for code generated by the compiler, it would be legal, for example, to read x and y, increment x, call f1, check y for a previously read value, and if it changes, go rage, search and destroy all Barneyβs videos and products, I donβt think that any real compilers generate code that would really do this, alas, but that would be allowed by standard).
supercat Aug 26 '10 at 15:52 2010-08-26 15:52
source share