[PATCH] Fix libstdc++/C++ fallout from RTL alias export
Richard Guenther
rguenther@suse.de
Wed Jan 20 16:00:00 GMT 2010
On Wed, 20 Jan 2010, Paolo Carlini wrote:
> On 01/20/2010 04:49 PM, Richard Guenther wrote:
> > Probably yes. I don't know if its implementation is very much
> > better though ;)
> >
> I get your irony, but note that the implementation is basically fully
> constrained by the specifications, thus if doesn't work vs aliasing, we
> have a DR, not a PR. The storage is reserved like this:
>
> template<std::size_t _Len>
> struct __aligned_storage_msa
> {
> union __type
> {
> unsigned char __data[_Len];
> struct __attribute__((__aligned__)) { } __align;
> };
> };
>
> What do you think? As far as I know, it has been invented exactly to
> deal in a clean way with such applications...
Sure - it will get you aligned storage. Still the question is
how you access that storage - the _Any_data way of using
*static_cast<_Tp*>(&_M_aligned_storage) wouldn't be any better.
shared_ptr_base.h uses placement new (not strictly required for
the middle-end) on top of aligned_storage. If such use ends up
being valid depends on that you only access the storage through
types that it was initialized with (with either placement new
or via a store of that type). This is where either functional
or the C++ frontend gets it wrong right now.
Richard.
More information about the Gcc-patches
mailing list