mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 21:38:44 +00:00
fix a few undefined behaviors exposed by the unit tests
Signed-off-by: Nuno Lopes <nlopes@microsoft.com>
This commit is contained in:
parent
091ae37c06
commit
379ce66391
|
@ -351,7 +351,7 @@ bool has_one_at_first_k_bits(unsigned sz, unsigned const * data, unsigned k) {
|
|||
}
|
||||
if (word_sz < sz) {
|
||||
unsigned bit_sz = k % (8 * sizeof(unsigned));
|
||||
unsigned mask = (1 << bit_sz) - 1;
|
||||
unsigned mask = (1u << bit_sz) - 1;
|
||||
return (data[word_sz] & mask) != 0;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -255,7 +255,7 @@ void mpff_manager::set(mpff & n, int64 v) {
|
|||
}
|
||||
else {
|
||||
if (v < 0) {
|
||||
set(n, static_cast<uint64>(-v));
|
||||
set(n, -static_cast<uint64>(v));
|
||||
n.m_sign = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -680,7 +680,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
|
||||
// Make sure that a and b have the same exponent.
|
||||
if (exp_a > exp_b) {
|
||||
unsigned shift = exp_a - exp_b;
|
||||
unsigned shift = (unsigned)exp_a - (unsigned)exp_b;
|
||||
n_sig_b = m_buffers[0].c_ptr();
|
||||
shr(m_precision, sig_b, shift, m_precision, n_sig_b);
|
||||
if (sgn_b != m_to_plus_inf && has_one_at_first_k_bits(m_precision, sig_b, shift)) {
|
||||
|
|
Loading…
Reference in a new issue