mirror of
https://github.com/Z3Prover/z3
synced 2025-07-26 06:07:01 +00:00
bit_vector: fix operator==() for the case that num_bits is a multiple of 32
Signed-off-by: Nuno Lopes <t-nclaud@microsoft.com>
This commit is contained in:
parent
39d7246251
commit
c824178e7e
2 changed files with 4 additions and 3 deletions
|
@ -116,7 +116,7 @@ void bit_vector::shift_right(unsigned k) {
|
|||
}
|
||||
}
|
||||
|
||||
bool bit_vector::operator==(bit_vector const & source) {
|
||||
bool bit_vector::operator==(bit_vector const & source) const {
|
||||
if (m_num_bits != source.m_num_bits)
|
||||
return false;
|
||||
unsigned n = num_words();
|
||||
|
@ -129,6 +129,7 @@ bool bit_vector::operator==(bit_vector const & source) {
|
|||
}
|
||||
unsigned bit_rest = source.m_num_bits % 32;
|
||||
unsigned mask = (1 << bit_rest) - 1;
|
||||
if (mask == 0) mask = UINT_MAX;
|
||||
return (m_data[i] & mask) == (source.m_data[i] & mask);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue