https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120432
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:91ed3248ce26aaaee4d7471aa4edbc07b3f1a90e commit r16-1259-g91ed3248ce26aaaee4d7471aa4edbc07b3f1a90e Author: Patrick Palka <ppa...@redhat.com> Date: Fri Jun 6 09:34:17 2025 -0400 libstdc++: Fix flat_map::operator[] for const lvalue keys [PR120432] The const lvalue operator[] overload wasn't properly forwarding the key type to the generic overload, causing a hard error for const keys. Rather than correcting the forwarded type this patch just makes the non-template overloads call try_emplace directly instead. That way we can remove the non-standard same_as constraint on the generic overload and match the spec more closely. PR libstdc++/120432 libstdc++-v3/ChangeLog: * include/std/flat_map (flat_map::operator[]): Make the non-template overloads call try_emplace directly. Remove non-standard same_as constraint on the template overload. * testsuite/23_containers/flat_map/1.cc (test08): New test. Reviewed-by: Tomasz KamiÅski <tkami...@redhat.com> Reviewed-by: Jonathan Wakely <jwak...@redhat.com>