Opened 5 years ago

Last modified 5 years ago

#13136 new Bugs

Regression: intrusive::unordered_set::rehash now requires T to be hashable

Reported by: gromer@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: intrusive
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc: fdegros@…

Description

It is possible to create an intrusive::unordered_set<T> where T is not hashable, so long as you never use methods that perform hashing (e.g. insertion is performed via insert_check and insert_commit, and lookup is performed with a caller-specified hasher). rehash is documented as not calling the hash function if store_hash is true, so it ought to be callable on a set with that option enabled, and as of Boost 1.60.0 it was. However, as of Boost 1.64.0 calls to rehash on such a set no longer compile, because the generated code now includes a call to the hash function (which will never actually be executed).

Suggested fix: make do_full_rehash a non-type template parameter rather than a function parameter of rehash_impl, and encapsulate the if(do_full_rehash) logic behind a function template that takes do_full_rehash as a template argument (with the two branches as different specializations). That way the code that calls the hash function will not be generated unless the user actually calls full_rehash.

Change History (1)

comment:1 by François Degros <fdegros@…>, 5 years ago

Cc: fdegros@… added
Note: See TracTickets for help on using tickets.