+2018-09-21 François Dumont <fdumont@gcc.gnu.org>
+
+ PR libstdc++/87135
+ * src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt):
+ Use __builtin_floor to compute _M_next_resize.
+ * testsuite/23_containers/unordered_set/hash_policy/71181.cc: Adapt.
+ * testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc:
+ Adapt.
+
2018-09-21 Jonathan Wakely <jwakely@redhat.com>
* testsuite/26_numerics/headers/cmath/hypot-long-double.cc: Remove.
if (__n < sizeof(__fast_bkt))
{
_M_next_resize =
- __builtin_ceil(__fast_bkt[__n] * (long double)_M_max_load_factor);
+ __builtin_floor(__fast_bkt[__n] * (long double)_M_max_load_factor);
return __fast_bkt[__n];
}
_M_next_resize = std::size_t(-1);
else
_M_next_resize =
- __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor);
+ __builtin_floor(*__next_bkt * (long double)_M_max_load_factor);
return *__next_bkt;
}
auto bkts = us.bucket_count();
for (int i = 0; i != threshold; ++i)
{
- if (i == nb_reserved)
+ if (i >= nb_reserved)
{
nb_reserved = bkts;
us.reserve(nb_reserved);
{
std::__detail::_Prime_rehash_policy policy;
- for (std::size_t i = 1;;)
+ // Starts at 4 because 2 & 3 are two consecutives primes that make this test
+ // fail.
+ for (std::size_t i = 4;;)
{
auto nxt = policy._M_next_bkt(i);
- if (nxt == i)
+ if (nxt <= i)
{
- // Equals only when reaching max.
- constexpr auto mx = std::numeric_limits<std::size_t>::max() - 1;
+ // Lower or equals only when reaching max prime.
+ constexpr auto mx = std::numeric_limits<std::size_t>::max();
VERIFY( nxt == policy._M_next_bkt(mx) );
break;
}
VERIFY( nxt > i );
- i = nxt;
+ i = nxt + 1;
}
}