Boost logo

Boost :

From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-12-05 11:19:57


(inline)

"Anthony Williams" <anthony.williamsNOSPAM_at_[hidden]> wrote in
message news:15855.9421.560000.173275_at_gargle.gargle.HOWL...

[snip]
> Gabriel Dos Reis writes:
> unsigned char* has _additional_ properties to void* --- you can access the
> object representation of _any_ object through an unsigned char* (and for
PODs,
> you can copy them around using this)
>
> 3.9p4:
> "The object representation of an object of type T is the sequence of N
> unsigned char objects taken up by the object of type T, where N equals
> sizeof(T)."
>
> 3.10p15:
> "If a program attempts to access the stored value of an object through
an
> lvalue of other than one of the following types the behavior is
undefined:
>
> - the dynamic type of the object,
>
> ...
>
> - a char or unsigned char type."
>

[snip]

> Thus, given that h.storage is properly aligned, (which is the purpose of
the
> other union member), after "new(h.storage) Foo", h.storage contains a Foo
> object. Thus accessing it through a pointer-to-Foo is legal, as Foo is the
> dynamic type of the object.
>

This is precisely my reasoning why reinterpret_cast<> is _not_
implementation defined.

It must be the case that it is equal to the situation of having

Foo* -> char */void* -> Foo* if Foo is the dynamic type of the object.

[snip]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk