|
|
|
|
|
by gpderetta
1843 days ago
|
|
To be pedantic, technically they can't elide, reorder or coalesce a accesses to volatile objects any more they can do any other form of I/O, even if it is a local variable whose address is never taken. Of course how accesses on the abstract machine maps to the actual hardware is implementation defined, although most will document to translate them to plain movs. And implementations have bugs of course; here [1] gcc removing a volatile access to an otherwise unused volatile parameter is considered a bug, even when the parameter is actually passed via register (in this case I would say the standard is underspecified). You are absolutely correct regarding non-volatile atomics though. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71793 |
|
There certainly are people who think volatile should mean something for stack variables, but the compiler people very much Do Not Care. So, by the technical wording of Standards, volatile means the same for all variables, in actual compilers (with certain exceptions) it does not.