This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]