]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Always instantiate key_type to compute hash code [PR115285]
authorFrançois Dumont <frs.dumont@gmail.com>
Tue, 22 Oct 2024 17:13:34 +0000 (19:13 +0200)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 10 Apr 2025 11:47:52 +0000 (12:47 +0100)
commit6343a0fef382a6f37f50755beb239f4e1e9e83cb
treebb4d8248a10df7681f9ef017cd755f7cfd6e53bb
parent51e041a9db714215d310bf69969de7b6f1c7c2bf
libstdc++: Always instantiate key_type to compute hash code [PR115285]

Even if it is possible to compute a hash code from the inserted arguments
we need to instantiate the key_type to guaranty hash code consistency.

Preserve the lazy instantiation of the mapped_type in the context of
associative containers.

libstdc++-v3/ChangeLog:

PR libstdc++/115285
* include/bits/hashtable.h (_S_forward_key<_Kt>): Always return a temporary
key_type instance.
* testsuite/23_containers/unordered_map/96088.cc: Adapt to additional instanciation.
Also check that mapped_type is not instantiated when there is no insertion.
* testsuite/23_containers/unordered_multimap/96088.cc: Adapt to additional
instanciation.
* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
* testsuite/23_containers/unordered_set/96088.cc: Likewise.
* testsuite/23_containers/unordered_set/pr115285.cc: New test case.

(cherry picked from commit ee030b28004eade3da872e7ae62a526a2940a705)
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_set/pr115285.cc [new file with mode: 0644]