diff --git a/base/common/wide_integer_impl.h b/base/common/wide_integer_impl.h index 5d757aed00e..f359647bddc 100644 --- a/base/common/wide_integer_impl.h +++ b/base/common/wide_integer_impl.h @@ -1127,12 +1127,8 @@ constexpr integer::operator T() const noexcept using UnsignedT = std::make_unsigned_t; UnsignedT res{}; - for (unsigned i = 0; i < _impl::item_count; ++i) - { - if constexpr (sizeof(T) > sizeof(base_type)) - res <<= (sizeof(base_type) * 8); - res += items[i]; - } + for (unsigned i = 0; i < _impl::item_count && i <= sizeof(T) / sizeof(base_type); ++i) + res += UnsignedT(items[i]) << (sizeof(base_type) * 8 * i); return res; }