[Bug libstdc++/93562] [8/9/10 Regression] unique_ptr::swap incorrectly uses generic std::swap
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 4 13:28:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93562
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:9962493ca2f71d3f3dd06b0e9cd19fcf849e3e4b
commit r10-6431-g9962493ca2f71d3f3dd06b0e9cd19fcf849e3e4b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Feb 4 12:59:14 2020 +0000
libstdc++: Fix regressions in unique_ptr::swap (PR 93562)
The requirements for this function are only that the deleter is
swappable, but we incorrectly require that the element type is complete
and that the deleter can be swapped using std::swap (which requires it
to be move cosntructible and move assignable).
The fix is to add __uniq_ptr_impl::swap which swaps the pointer and
deleter individually, instead of using the generic std::swap on the
tuple containing them.
PR libstdc++/93562
* include/bits/unique_ptr.h (__uniq_ptr_impl::swap): Define.
(unique_ptr::swap, unique_ptr<T[], D>::swap): Call it.
* testsuite/20_util/unique_ptr/modifiers/93562.cc: New test.
More information about the Gcc-bugs
mailing list