https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103501
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:bae757f80970824fbc6a1a2598b233ff489efa4a commit r11-9438-gbae757f80970824fbc6a1a2598b233ff489efa4a Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue Nov 30 23:32:50 2021 +0000 libstdc++: Clear RB tree after moving elements [PR103501] If the allocator-extended move constructor move-constructs each element into the new container, the contents of the old container are left in moved-from states. We cannot know if those states preserve the container's ordering and uniqueness guarantees, so just erase all moved-from elements. libstdc++-v3/ChangeLog: PR libstdc++/103501 * include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&, false_type)): Clear container if elements have been moved-from. * testsuite/23_containers/map/allocator/move_cons.cc: Expect moved-from container to be empty. * testsuite/23_containers/multimap/allocator/move_cons.cc: Likewise. * testsuite/23_containers/multiset/allocator/103501.cc: New test. * testsuite/23_containers/set/allocator/103501.cc: New test. (cherry picked from commit 056551414a328b427c4bf4955b9a3832f344685c)