public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* reinterpret_casting a non-POD
@ 2008-08-16 12:31 Philip
  2008-08-17  4:08 ` Eljay Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Philip @ 2008-08-16 12:31 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-16 12:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-16 12:31 reinterpret_casting a non-POD Philip
2008-08-17  4:08 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).