|
Boost : |
From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-12-05 11:52:49
"Anthony Williams" <anthony.williamsNOSPAM_at_[hidden]> wrote in
message news:15855.33204.759000.122558_at_gargle.gargle.HOWL...
> 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
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.
>
> Nowhere do I see a requirement that supports your deductions. Indeed there
are
> very few requirements on reinterpret_cast<>, other than the fact that what
it
> 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
stricter
> 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
pointer
> to the struct, and vice-versa.
>
> * A Null pointer of any type can be cast to a null pointer of any other
type.
>
> Anthony
> --
> Anthony Williams
> Senior Software Engineer, Beran Instruments Ltd.
> Remove NOSPAM when replying, for timely response.
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk