3 ms·
Your examples are not expected to work unless you specifically ask the compiler for it. If you use the volatile key word, then you are guaranteed that all read
by im3w1l 11y ago
Your examples are not expected to work unless you specifically ask the compiler for it.
If you use the volatile key word, then you are guaranteed that all reads and stores will actually happen and not be optimized out. But volatile still allows non-atomicity and reordering so you probably want something which prohibits that too.