[Boost-bugs] [Boost C++ Libraries] #12229: intrusive::unordered_set<T>::rehash() broken

Subject: [Boost-bugs] [Boost C++ Libraries] #12229: intrusive::unordered_set<T>::rehash() broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-05-27 11:13:19

#12229: intrusive::unordered_set<T>::rehash() broken
 Reporter: Christian Kaiser <boost@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: intrusive
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
 I do use the intrusive::unordered_set<T> to store language-dependent
 objects, and when the language changes, I used to use


 to update the buckets. Notice the bucket count does not change!

 As it is now (1.61), "fast_shrink" becomes true:

       const bool fast_shrink = (!incremental) && (old_bucket_count >=
 new_bucket_count) &&
          (power_2_buckets || (old_bucket_count % new_bucket_count) == 0);

 while in the previouis version used, it was

       const bool fast_shrink = (!incremental) && (old_bucket_count >
 new_bucket_count) &&
          (power_2_buckets ||(old_bucket_count % new_bucket_count) == 0);

 and "fast_shrink" was false.

 Due to

       if(same_buffer && fast_shrink && (n < new_bucket_count)){
          new_first_bucket_num = n;
          n = new_bucket_count;

 the "n" is set to the bucket count, and the loop that is rehashing is
 '''NOT''' entered any more, thus rehash() does nothing any more.

 This is according to the documentation, but a change in behaviour. So I
 add this as as a warning that the change might cause trouble for some
 people. A "rehash(bucket_size+1)" still does its job, though not as
 optimal as the size is then not a prime any more. An optional
 "force_rehash" parameter or such to the rehash() function might be handy.

Ticket URL: <https://svn.boost.org/trac/boost/ticket/12229>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC