Boost logo

Boost :

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


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

> 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
> 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
> lvalue of other than one of the following types the behavior is
> - the dynamic type of the object,
> ...
> - a char or unsigned char type."


> Thus, given that is properly aligned, (which is the purpose of
> other union member), after "new( Foo", 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at