Make rehash(0) work with ubsan's unsigned-integer-overflow.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40743
This commit is contained in:
Dan Albert
2017-12-12 21:12:55 -08:00
parent 6cc7418a43
commit 4e68975021

View File

@@ -2137,7 +2137,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
void void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
{ {
if (__n == 1) if (__n < 2)
__n = 2; __n = 2;
else if (__n & (__n - 1)) else if (__n & (__n - 1))
__n = __next_prime(__n); __n = __next_prime(__n);