This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
reinterpret_casting a non-POD
- From: Philip <snzzbk at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 16 Aug 2008 07:42:00 -0400
- Subject: reinterpret_casting a non-POD
Given a simple but currently non-POD class such as:
struct Point
{
float x, y, z;
Point () {}
Point (float x_, float y_, float z_): x (x_), y (y_), z (z_) {}
};
Is there any risk involved in the following operations?:
Point p;
float* pp = reinterpret_cast<float*> (&p);
void* buffer = // acquire memory
Point* points = reinterpret_cast<Point*> (buffer);
// do stuff that treats buffer as array of Points
float* floats = reinterpret_cast<float*> (points);
Thanks.