Re: address of compound

>From the Standard, at 9.2, para 17:

A pointer to a POD-struct object, suitably
converted using a reinterpret_cast, points to its
initial member (or if that member is a bit-field,
then to the unit in which it resides) and vice
versa. [Note: There might therefore be unnamed
padding within a POD-struct object, but not at its
beginning, as necessary to achieve appropriate
alignment. ]

In your example, "C"'s initial member is "a", of type A; "A"'s initial member
is "x", of type double; and "c" is of type C.

Given types C and A are POD-struct types (which they are), and that you use
reinterpret_cast (which you have), your program appears (to me) to be Standard
compliant. Of course, don't take my word for it; wait for Steve Clamage.
--Thomas 


--- GoldED/386 2.42.G0614+
 * Origin: Everything goes the bach runter ... 
 * http://www.universityedu.org

Received on Thursday, 10 March 2005 14:08:43 UTC