Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-10-01 20:03:12


on Fri Sep 21 2007, "Marco Servetto" <marco.servetto-AT-gmail.com> wrote:

> Hello,
> Supposing having
> struct A{
> int a1;
> double a2;
> int a3[3];
> };
> struct B{
> int b1;
> double b2;
> int b3[3];
> };
>
> A and B are two structure with same strucutural type but different
> name, (and different name for fields...)
>
> The question is: C++ grants that
> A a;
> a.a2=8.8;
> assert(reinterpret_cast<B*>(&a)->b2==8.8);

C++ guarantees very, very little about reinterpret_cast, and certainly
not that. In general the results of reinterpret_cast are
implementation-defined.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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