[Bug libstdc++/103501] associative containers left invalid after allocator-extended move construction

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 1 15:08:07 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103501

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:056551414a328b427c4bf4955b9a3832f344685c

commit r12-5693-g056551414a328b427c4bf4955b9a3832f344685c
Author: Jonathan Wakely <jwakely@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.


More information about the Gcc-bugs mailing list