[Bug libstdc++/125374] std::flat_map unconditionally moves from lvalue keys in _M_try_emplace

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 21 17:20:34 GMT 2026


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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:c9cc091338b13835afbb0f5d68bfde80da172fd2

commit r15-11191-gc9cc091338b13835afbb0f5d68bfde80da172fd2
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue May 19 13:43:10 2026 -0400

    libstdc++: Fix incorrect move in flat_map::_M_try_emplace [PR125374]

            PR libstdc++/125374

    libstdc++-v3/ChangeLog:

            * include/std/flat_map (_Flat_map_impl::_M_try_emplace): Forward
            instead of unconditionally moving __k when inserting it.
            * testsuite/23_containers/flat_map/1.cc (test10): New test.

    Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
    (cherry picked from commit 6d114645fa1c9831a109c8a8934685f49364818a)


More information about the Gcc-bugs mailing list