
21 Sep
2004
21 Sep
'04
12:33 p.m.
Ben Hutchings wrote:
Note also that the compiler could also hoist the test of the control variable out of the loop if it can tell that nothing in that loop will modify the control variable. This seems to me to be a more likely problem.
It is possible that "volatile" may help you to ensure visibility, but the semantics of volatile are implementation-dependent and not well specified.
Arguably, volatile is quite rigidly specified. In particular, a compiler is not allowed to hoist a test of a volatile variable out of a loop because this alters the observable behavior, by definition.