3 ms·
The C volatile keyword doesn't have well-defined behaviour, but I'm pretty sure there is no compiler where volatile causes extra memory fence instructions to be
by rwmj 8y ago
The C volatile keyword doesn't have well-defined behaviour, but I'm pretty sure there is no compiler where volatile causes extra memory fence instructions to be emitted. It's just a flag hinting not to keep the value in a register.
- cwzwarich 8y agoI believe Microsoft compilers have traditionally treated volatile as having ordering properties (giving reads acquire semantics and writes release semantics). On x86, this just results in compiler-only barriers, but on Itanium this would result in actual barrier instructions. This is far from a standard behavior, though.
- gpderetta 8y agoI think this behaviour has been considered a mistake and is disabled by default in recent msvc versions