Ping for this bug fix, would you like a PR ?

On 20/01/2025 22:12, François Dumont wrote:
Hi

In my work on fancy pointer support I've decided to always cache the hash code.

Doing so I spotted a bug in the management of this cache when hash functor is stateful.

    libstdc++: [_Hashtable] Fix hash code cache usage when hash functor is stateful

    It is wrong to reuse a cached hash code when this code depends then on the state
    of the Hash functor.

    Add checks that Hash functor is stateless before reusing the cached hash code.

    libstdc++-v3/ChangeLog:

            * include/bits/hashtable_policy.h (_Hash_code_base::_M_copy_code): Remove.
            * include/bits/hashtable.h (_M_copy_code): New.
            (_M_assign): Use latter.
            (_M_bucket_index_ex): New.
            (_M_equals): Use latter.
            * testsuite/23_containers/unordered_map/modifiers/merge.cc (test10): New
            test case.

Tested under Linux x64, ok to commit ?

François

Reply via email to