Landing: 6d114645fa1c

Project / Subsystem

gcc / libstdc++

Date

2026-05-19

Author

Patrick Palka

Commit

6d114645fa1c9831a109c8a8934685f49364818a

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
libstdc++
patch_id
commit_hash
6d114645fa1c9831a109c8a8934685f49364818a
source_type
github
headline
Fixes incorrect move operation in flat_map emplace.
tldr
The libstdc++ `flat_map` now correctly forwards the key in `_M_try_emplace`, preventing potential issues when inserting new elements.
author
Patrick Palka
outcome
committed
performance_win
false
breaking_change
false
series_id
series_parts
[]
tags
  • libstdc++
  • flat_map
  • bugfix
  • containers
discussion_id_link
bugzilla_pr
date
2026-05-19T00:00:00.000Z

This commit fixes an issue in the flat_map implementation where the key was unconditionally moved instead of forwarded during insertion in the _M_try_emplace function. This could lead to incorrect behavior or prevent insertion when the key type doesn’t support move operations. The fix ensures that the key is forwarded, allowing for correct construction of the element in place. A new test case, test10 in 23_containers/flat_map/1.cc, validates the fix.