This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] Fix std::experimental::any for small, non-trivial objects
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Daniel Krügler <daniel dot kruegler at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 2 May 2015 18:33:03 +0100
- Subject: Re: [patch] Fix std::experimental::any for small, non-trivial objects
- Authentication-results: sourceware.org; auth=none
- References: <20150502123920 dot GW3618 at redhat dot com> <20150502130359 dot GY3618 at redhat dot com> <CAGNvRgD=bfouktexLpx2UXazV7Fe0X3A9A49QXXH5fU-oxJ5vw at mail dot gmail dot com>
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.