From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-12-05 11:52:49
"Anthony Williams" <anthony.williamsNOSPAM_at_[hidden]> wrote in
> Eric Woodruff writes:
> > "Anthony Williams" <anthony.williamsNOSPAM_at_[hidden]> wrote in
> > message news:15855.9421.560000.173275_at_gargle.gargle.HOWL...
> > > Thus, given that h.storage is properly aligned, (which is the purpose
> > the
> > > other union member), after "new(h.storage) Foo", h.storage contains a
> > > object. Thus accessing it through a pointer-to-Foo is legal, as Foo
> > > 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.
> Nowhere do I see a requirement that supports your deductions. Indeed there
> very few requirements on reinterpret_cast<>, other than the fact that what
> does must be defined by the implementation. For pointers to objects, these
> amount to:
> * T1* can be converted to T2* and back again unchanged (unless T2 has
> alignment requirements).
Precisely, T1 is Foo in this case as you have already pointed out. This is
simply the identity conversion T1 -> T2 -> T1, which is pretty much the only
thing reinterpret_cast can do portably.
> * You can convert a pointer to the first member of a POD struct to a
> to the struct, and vice-versa.
> * A Null pointer of any type can be cast to a null pointer of any other
> Anthony Williams
> Senior Software Engineer, Beran Instruments Ltd.
> Remove NOSPAM when replying, for timely response.
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk