[cpp-threads] C++ memory model
Peter Dimov
pdimov at mmltd.net
Tue Sep 22 22:03:53 BST 2009
Lawrence Crowl wrote:
>> Adding "[Note: Executions that access atomic or locking objects as
>> non-atomic objects, through an array of character type, for example,
>> will have undefined behaviour - end note]"
>
> As did Clark, I note that mixed non-atomic and atomic accesses were
> not intended.
I, for one, have always intended mixed accesses to be supported (in a
race-free program, of course).
> I think I think there is at least evidence that atomics
> are not char accessible. Section 3.9 defines memcpy to be valid only
> for trivially copyable types.
This is not true for reads. You can read the storage bytes of any object
with memcpy. (*)
What specific problem are people trying to fix by outlawing mixed access?
(*) And you can legally read the first member (and maybe the other members,
I'm not 100% sure) of a standard-layout type by using an appropriate cast.
More information about the cpp-threads
mailing list