Fix negative shift value UB

This commit is contained in:
Matt Borland
2023-06-12 15:12:33 +02:00
parent 35cae5d3d8
commit f73af1a67d

View File

@@ -722,7 +722,11 @@ BOOST_CHARCONV_CXX14_CONSTEXPR void div_impl(uint128 lhs, uint128 rhs, uint128&
uint128 denom = rhs;
quotient = 0U;
const int shift = high_bit(lhs) - high_bit(rhs);
std::int32_t shift = high_bit(lhs) - high_bit(rhs);
if (shift < 0)
{
shift = 32 - shift;
}
denom <<= shift;
for (int i = 0; i <= shift; ++i)