std::vector move assign patch
François Dumont
frs.dumont@gmail.com
Fri Dec 27 18:28:00 GMT 2013
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 <fdumont@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.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector.patch
Type: text/x-patch
Size: 7056 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20131227/a41391fa/attachment.bin>
More information about the Libstdc++
mailing list