-
- Downloads
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. From-SVN: r277113
Showing
- libstdc++-v3/ChangeLog 14 additions, 0 deletionslibstdc++-v3/ChangeLog
- libstdc++-v3/include/bits/forward_list.h 2 additions, 2 deletionslibstdc++-v3/include/bits/forward_list.h
- libstdc++-v3/include/bits/stl_deque.h 2 additions, 2 deletionslibstdc++-v3/include/bits/stl_deque.h
- libstdc++-v3/include/bits/stl_list.h 2 additions, 2 deletionslibstdc++-v3/include/bits/stl_list.h
- libstdc++-v3/include/bits/stl_vector.h 3 additions, 2 deletionslibstdc++-v3/include/bits/stl_vector.h
- libstdc++-v3/testsuite/23_containers/deque/92124.cc 49 additions, 0 deletionslibstdc++-v3/testsuite/23_containers/deque/92124.cc
- libstdc++-v3/testsuite/23_containers/forward_list/92124.cc 49 additions, 0 deletionslibstdc++-v3/testsuite/23_containers/forward_list/92124.cc
- libstdc++-v3/testsuite/23_containers/list/92124.cc 49 additions, 0 deletionslibstdc++-v3/testsuite/23_containers/list/92124.cc
- libstdc++-v3/testsuite/23_containers/vector/92124.cc 49 additions, 0 deletionslibstdc++-v3/testsuite/23_containers/vector/92124.cc
Loading
Please register or sign in to comment