Assign volatile to non-volatile sematics and the C standard
问题 volatile int vfoo = 0; void func() { int bar; do { bar = vfoo; // L.7 }while(bar!=1); return; } This code busy-waits for the variable to turn to 1 . If on first pass vfoo is not set to 1 , will I get stuck inside. This code compiles without warning. What does the standard say about this? vfoo is declared as volatile . Therefore, read to this variable should not be optimized. However, bar is not volatile qualified. Is the compiler allowed to optimize the write to this bar ? .i.e. the compiler