diff --git a/sstables/sstables.cc b/sstables/sstables.cc index d2e7a839f7..eeb6194cb2 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -130,10 +130,10 @@ static void check_buf_size(temporary_buffer& buf, size_t expected) { template static void check_truncate_and_assign(T& to, const U from) { static_assert(std::is_integral::value && std::is_integral::value, "T and U must be integral"); - if (from >= std::numeric_limits::max()) { - throw std::overflow_error("assigning U to T would cause an overflow"); - } to = from; + if (to != from) { + throw std::overflow_error("assigning U to T caused an overflow"); + } } // Base parser, parses an integer type