Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions libcxx/src/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <__hash_table>
#include <algorithm>
#include <stdexcept>
#include <type_traits>

_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")

Expand Down Expand Up @@ -52,16 +51,15 @@ const unsigned indices[] = {
// are fewer potential primes to search, and fewer potential primes to divide
// against.

template <size_t _Sz = sizeof(size_t)>
inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 4, void>::type __check_for_overflow(size_t N) {
if (N > 0xFFFFFFFB)
std::__throw_overflow_error("__next_prime overflow");
}

template <size_t _Sz = sizeof(size_t)>
inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 8, void>::type __check_for_overflow(size_t N) {
if (N > 0xFFFFFFFFFFFFFFC5ull)
std::__throw_overflow_error("__next_prime overflow");
inline void __check_for_overflow(size_t N) {
if constexpr (sizeof(size_t) == 4) {
if (N > 0xFFFFFFFB)
std::__throw_overflow_error("__next_prime overflow");
} else {
static_assert(sizeof(size_t) == 8);
if (N > 0xFFFFFFFFFFFFFFC5ull)
std::__throw_overflow_error("__next_prime overflow");
}
}

size_t __next_prime(size_t n) {
Expand Down
Loading