https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92124
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Thu Oct 17 14:21:27 2019 New Revision: 277113 URL: https://gcc.gnu.org/viewcvs?rev=277113&root=gcc&view=rev Log: PR libstdc++/92124 fix incorrect container move assignment The container requirements say that for move assignment "All existing elements of [the target] are either move assigned or destroyed". Some of our containers currently use __make_move_if_noexcept which makes the move depend on whether the element type is nothrow move constructible. This is incorrect, because the standard says we must move assign, not move or copy depending on the move constructor. Use make_move_iterator instead so that we move unconditionally. This ensures existing elements won't be copy assigned. PR libstdc++/92124 * include/bits/forward_list.h (_M_move_assign(forward_list&&, false_type)): Do not use __make_move_if_noexcept, instead move unconditionally. * include/bits/stl_deque.h (_M_move_assign2(deque&&, false_type)): Likewise. * include/bits/stl_list.h (_M_move_assign(list&&, false_type)): Likewise. * include/bits/stl_vector.h (_M_move_assign(vector&&, false_type)): Likewise. * testsuite/23_containers/vector/92124.cc: New test. Added: trunk/libstdc++-v3/testsuite/23_containers/deque/92124.cc trunk/libstdc++-v3/testsuite/23_containers/forward_list/92124.cc trunk/libstdc++-v3/testsuite/23_containers/list/92124.cc trunk/libstdc++-v3/testsuite/23_containers/vector/92124.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/forward_list.h trunk/libstdc++-v3/include/bits/stl_deque.h trunk/libstdc++-v3/include/bits/stl_list.h trunk/libstdc++-v3/include/bits/stl_vector.h
