reinterpret_casting a non-POD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux