R
REH
I believe the consensus of this group is that volatile does not
protect against code reordering. But I am not convinced. The standard
says that "accesses to volatile objects are evaluated strictly
according to the rules of the abstract machine." A later note states
"An implementation might define a one-to-one correspondence between
abstract and actual semantics: at every sequence point, the values of
the actual objects would agree with those specified by the abstract
semantics. The keyword volatile would then be redundant."
I would take the above to mean that it does guarantee order (a least
relative to other volatile sequence points). Assuming that the
reordering of statements is an optimization, and volatile inhibits
optimization, it follows that volatile would guarantee order. I am
missing something, or am I misinterpreting the above quotes?
Thanks,
REH
protect against code reordering. But I am not convinced. The standard
says that "accesses to volatile objects are evaluated strictly
according to the rules of the abstract machine." A later note states
"An implementation might define a one-to-one correspondence between
abstract and actual semantics: at every sequence point, the values of
the actual objects would agree with those specified by the abstract
semantics. The keyword volatile would then be redundant."
I would take the above to mean that it does guarantee order (a least
relative to other volatile sequence points). Assuming that the
reordering of statements is an optimization, and volatile inhibits
optimization, it follows that volatile would guarantee order. I am
missing something, or am I misinterpreting the above quotes?
Thanks,
REH