Skip to content

Commit a0fbb70

Browse files
committed
Make changes for tests in boostorg/math#1267
1 parent 9de48c7 commit a0fbb70

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/boost/multiprecision/cpp_int/bitwise.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,9 @@ inline BOOST_MP_CXX14_CONSTEXPR void left_shift_limb(Int& result, double_limb_ty
396396
template <class Int>
397397
inline BOOST_MP_CXX14_CONSTEXPR void left_shift_generic(Int& result, double_limb_type s)
398398
{
399-
limb_type offset = static_cast<limb_type>(s / Int::limb_bits);
400-
limb_type shift = static_cast<limb_type>(s % Int::limb_bits);
399+
const limb_type offset = static_cast<limb_type>(s / Int::limb_bits);
400+
const limb_type shift = static_cast<limb_type>(s % Int::limb_bits);
401+
BOOST_ASSERT(shift < sizeof(pr[0]) * CHAR_BIT);
401402

402403
std::size_t ors = result.size();
403404
if ((ors == 1) && (!*result.limbs()))
@@ -438,6 +439,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void left_shift_generic(Int& result, double_limb
438439
}
439440
for (; rs - i >= static_cast<std::size_t>(static_cast<std::size_t>(2u) + offset); ++i)
440441
{
442+
BOOST_ASSERT(shift < sizeof(pr[0]) * CHAR_BIT);
441443
pr[rs - 1 - i] = pr[rs - 1 - i - offset] << shift;
442444
pr[rs - 1 - i] |= pr[rs - 2 - i - offset] >> (Int::limb_bits - shift);
443445
}

0 commit comments

Comments
 (0)