[patch] Fix std::experimental::any for small, non-trivial objects
Jonathan Wakely
jwakely@redhat.com
Sat May 2 17:33:00 GMT 2015
On 02/05/15 19:05 +0200, Daniel Krügler wrote:
>Not related to the patch, but is the second template argument of
>any::_Storage::_M_buffer really correct:
>
>std::aligned_storage<sizeof(_M_ptr), sizeof(_M_ptr)>::type _M_buffer;
>
>I would have expected to see this to be an alignment value.
Yes, that looks like a typo.
We could remove that second argument completely, although that might
increase the alignment requirements on any (probably not in practice).
Looking at it now, I think the _Internal alias template should also
check that alignof(_Tp) <= alignof(void*) so that it can safely be
stored in the _Storage.
Otherwise a type with sizeof(T) <= sizeof(void*) but
alignof(T) > alignof(void*) would not be correctly aligned when stored
in the buffer.
More information about the Libstdc++
mailing list