[Bug libstdc++/85517] std::variant exception safety problems

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 4 18:21:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85517

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Xiaoyi Zhang from comment #0)
> 2. Conversion assignment operator=(T&&)
> According to [variant.assign] 23.7.3.3 (11.3): if
> is_nothrow_constructible<Tj, T> == false &&
> is_nothrow_move_constructible<Tj> == true, equivalent to
> operator=(variant(std::forward<T>(t))).
> 
> Failure case: If Tj has a nothrow move constructor, the standard requires
> strong guarantee (that a temporary variant be created first and move it into
> *this). The current implementation always invokes emplace(), which has only
> basic guarantee.

My patch on PR 87431 comment 10 fixes this, by giving emplace the strong
guarantee for such types.


More information about the Gcc-bugs mailing list