[PATCH] PR libstdc++/87855 fix optional for types with non-trivial copy/move
Jonathan Wakely
jwakely@redhat.com
Wed Jan 9 10:40:00 GMT 2019
On 08/01/19 23:00 +0000, Jonathan Wakely wrote:
>When the contained value is not trivially copy (or move) constructible
>the union's copy (or move) constructor will be deleted, and so the
>_Optional_payload delegating constructors are invalid. G++ fails to
>diagnose this because it incorrectly performs copy elision in the
>delegating constructors. Clang does diagnose it (llvm.org/PR40245).
>
>The solution is to avoid performing any copy (or move) when the
>contained value's copy (or move) constructor isn't trivial. Instead the
>contained value can be constructed by calling _M_construct. This is OK,
>because the relevant constructor doesn't need to be constexpr when the
>contained value isn't trivially copy (or move) constructible.
>
>Additionally, this patch removes a lot of code duplication in the
>_Optional_payload partial specializations and the _Optional_base partial
>specialization, by hoisting it into common base classes.
This follow-up patch removes a little more code duplication from those
partial specializations.
Tested x86_64-linux. Ville already ack'd this, so I'm committing it to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4208 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190109/8f47cbb4/attachment.bin>
More information about the Libstdc++
mailing list