Committed with the advised changes. Ok, I'll backport next week. Thanks On 19/10/2023 10:05, Jonathan Wakely wrote: > > > On Thursday, 19 October 2023, François Dumont > wrote: > > libstdc++: [_Hashtable] Do not reuse untrusted cached hash code > > > > On merge reuse merged node cached hash code only if we are on the > same type of > > hash and this hash is stateless. Usage of function pointers or > std::function as > > hash functor will prevent this optimization. > > I found this first sentence a little hard to parse. How about: > > On merge, reuse a merged node's cached hash code only if we are on the > same > type of > hash and this hash is stateless. > > > And for the second sentence, would it be clearer to say "will prevent > reusing cached hash codes" instead of "will prevent this optimization"? > > > And for the comment on the new function, I think this reads better: > > "Only use the node's (possibly cached) hash code if its hash function > _H2 matches _Hash. Otherwise recompute it using _Hash." > > The code and tests look good, so if you're happy with the > comment+changelog suggestions, this is ok for trunk. > > This seems like a bug fix that should be backported too, after some > time on trunk. > > > > > > libstdc++-v3/ChangeLog > > > >     * include/bits/hashtable_policy.h > >     (_Hash_code_base::_M_hash_code(const _Hash&, const > _Hash_node_value<>&)): Remove. > >     (_Hash_code_base::_M_hash_code<_H2>(const _H2&, const > _Hash_node_value<>&)): Remove. > >     * include/bits/hashtable.h > >     (_M_src_hash_code<_H2>(const _H2&, const key_type&, const > __node_value_type&)): New. > >     (_M_merge_unique<>, _M_merge_multi<>): Use latter. > >     * testsuite/23_containers/unordered_map/modifiers/merge.cc > >     (test04, test05, test06): New test cases. > > > > Tested under Linux x86_64, ok to commit ? > > > > François > > > >