[cpp-threads] RE: volatile, memory models, threads

Peter Dimov pdimov at mmltd.net
Wed Mar 1 11:27:10 GMT 2006


Nick Maclaren wrote:

> 3.9/4 defines "object representation" and "value representation", but
> 3.9.3/1 refers to the "representation requirements".

Right, and it is the object representation that is the subject of 3.9.3/1.
"shall have the same representation and (alignment requirements)." Object
representation includes size (among other things).

> The footnote
> clarifies that this is intended to imply interchangeability as
> arguments, return values and members of unions.  Now, it may surprise
> you, but there have been (and probably still are) implementations
> where arguments and return values are different sizes from the SAME
> value in ordinary objects.  That is possible and permitted.

No. sizeof(x) is always the same when x is of type cv X, no matter whether x
is an argument, return value, or part of an array, and the object
representation of x is always the sequence of sizeof(x) == sizeof(X) bytes,
starting from &x. It may well be the case that physically, padding is 
inserted between x1 and x2 so that the arguments occupy more space than they 
would otherwise, but this doesn't change the representation of x1 or x2. A 
conforming program is still allowed to inspect the object representation 
byte by byte (or copy it into another object of the same type for PODs.) 




More information about the cpp-threads mailing list