On 9 January 2014 12:22, H.J. Lu wrote: > On Fri, Dec 27, 2013 at 10:27 AM, François Dumont <frs.dum...@gmail.com> > wrote: >> Hi >> >> Here is a patch to fix an issue in normal mode during the move >> assignment. The destination vector allocator instance is moved too during >> the assignment which is wrong. >> >> As I discover this problem while working on issues with management of >> safe iterators during move operations this patch also fix those issues in >> the debug mode for the vector container. Fixes for other containers in debug >> mode will come later. >> >> 2013-12-27 François Dumont <fdum...@gcc.gnu.org> >> >> * include/bits/stl_vector.h (std::vector<>::_M_move_assign): Pass >> *this allocator instance when building temporary vector instance >> so that *this allocator do not get moved. >> * include/debug/safe_base.h >> (_Safe_sequence_base(_Safe_sequence_base&&)): New. >> * include/debug/vector (__gnu_debug::vector<>(vector&&)): Use >> latter. >> (__gnu_debug::vector<>(vector&&, const allocator_type&)): Swap >> safe iterators if the instance is moved. >> (__gnu_debug::vector<>::operator=(vector&&)): Likewise. >> * testsuite/23_containers/vector/allocator/move.cc (test01): Add >> check on a vector iterator. >> * testsuite/23_containers/vector/allocator/move_assign.cc >> (test02): Likewise. >> (test03): New, test with a non-propagating allocator. >> * testsuite/23_containers/vector/debug/move_assign_neg.cc: New. >> >> Tested under Linux x86_64 normal and debug modes. >> >> I will be in vacation for a week starting today so if you want to apply it >> quickly do not hesitate to do it yourself. >> > > This caused: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59738
Fixed by the attached patch, tested x86_64-linux and committed to trunk. I've also rotated the libstdc++ ChangeLog. 2014-01-09 Jonathan Wakely <jwak...@redhat.com> PR libstdc++/59738 * include/bits/stl_vector.h (vector<>::_M_move_assign): Restore support for non-Movable types.
commit c12a0d112781150c2888de7c63960e22ef4ffcbb Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Jan 9 16:50:50 2014 +0000 PR libstdc++/59738 * include/bits/stl_vector.h (vector<>::_M_move_assign): Restore support for non-Movable types. diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 3638a8c..2cedd39 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -1433,7 +1433,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void _M_move_assign(vector&& __x, std::true_type) noexcept { - const vector __tmp(std::move(*this), get_allocator()); + vector __tmp(get_allocator()); + this->_M_impl._M_swap_data(__tmp._M_impl); this->_M_impl._M_swap_data(__x._M_impl); if (_Alloc_traits::_S_propagate_on_move_assign()) std::__alloc_on_move(_M_get_Tp_allocator(),