
2 Oct
2007
2 Oct
'07
12:03 a.m.
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