[cpp-threads] memory model
Peter Dimov
pdimov at mmltd.net
Sun May 8 17:15:24 BST 2005
Peter Dimov wrote:
> Comments on the proposed memory model document:
It took me a while to realize this, but the definition of "canonical
execution" is flawed.
The C++ abstract machine has no notion of reading from a non-volatile
variable. That's why "side effects" only includes object modifications.
If you have:
int a = 0;
the value of the expression 'a' is 0. There is no "read" involved in this
evaluation; the value of 'a' is just zero, period. (The compiler is allowed
to never touch the actual storage of 'a' if it can determine the value by
other means.)
When a side effect modifies 'a' to be 1, the value of 'a' after this side
effect is committed (after the first subsequent sequence point) is now 1.
So you have the flow:
...
a == 0
a == 0
<sequence point>
a == unspecified
side effect sets a to 1
a == unspecified
<sequence point>
a == 1
a == 1
...
More information about the cpp-threads
mailing list