David Brown wrote:
The point is, the compiler is allowed to do this sort of optimisation.
It can be a bit annoying during testing and debugging - especially
because such reorderings are relatively rare in practice, so that it's
easy to think "it worked before, what's wrong now?".
I wouldn't have thought the compiler was allowed to re-order statements
*around* a volatile access. Perhaps someone can help my understanding, given
:-
1: Volatile Statements<sp>
2: Statements<sp>
3: Volatile Statements<sp>
where <sp> is a sequence point.
Line 3 has a volatile access and therefore has side-effects that the
compiler doesn't know about, so surely it must complete all preceeding
statements up to and including the sequence point before the volatile access
occurs?
Jon