[cpp-threads] memory model

Peter Dimov pdimov at mmltd.net
Fri Apr 29 14:01:43 BST 2005


Doug Lea wrote:
>> On an unrelated note, I wonder what the semantics of x = y are
>> supposed to be under the new volatile when x and y are volatile
>> variables of a struct type that contains two or more pointers (this
>> code is valid today, so it can't be made a compile-time error.)
>
> Right. This is why "volatile" is not the same as "atomic".
> You always get barriers, but loads/stores of only those
> volatile variables smaller than some platform-dependent size are also
> atomic.

This means that volatile-based code that is correct on platform A will 
silently compile and do the wrong thing on platform B, right? 





More information about the cpp-threads mailing list