|
Boost : |
Subject: Re: [boost] aligned_storage in unions
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-09-22 16:03:38
On 22/09/2010 20:05, Larry Evans wrote:
> I thought variant just static_cast<char*> to void* then from void* to
> T*.
As far as I'm concerned, this is the same thing.
> The char* is for the memory buffer in boost::aligned_storage.
> IOW, it doesn't use reinterpret_cast. To confirm, I did:
>
> find . -name \*.hpp -exec grep _cast {} \; -ls
>
> in boost/variant and only found static_cast.
>
> Now, as far as Frank's point about operator=, my reply to his
> post indicated there would never be a case where two pointers
> of different types and pointing to the same memory location
> would be in scope at the same time in the operator= implementation,
> at least for the container_one_of_maybe mentioned in my reply.
> I don't know if that is true for boost::variant.
A first try is to ask GCC if you break the strict aliasing rules.
Compile some test code with -O3 -Wstrict-aliasing and see if it says
something.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk