Subject: Re: [boost] aligned_storage in unions
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2010-09-23 09:27:17
-----BEGIN PGP SIGNED MESSAGE-----
On Wednesday 22 September 2010, Larry Evans wrote:
> I'm using gcc version 4.5.
> I changed to to actually dereference the pointer. I also added the
> -fstrict-aliasing flag; however, I'm still not getting any errors.
> Code and compilation output attached.
You know, after re-reading the standard, I think the placement new makes it
okay (aside from the undefined behaviour in your example of accessing a
destroyed object). The standard only refers to objects and their dynamic
types, as opposed to memory addresses (which is what I had in my head). So
the placement new would set the dynamic type of the new object, and then it
is okay to access it through an lvalue expression that is compatible with the
new dynamic type of the object.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk