3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-14 04:48:45 +00:00

Fix is_int64 bug in mpz when compiling with GMP

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-04-08 14:50:17 -07:00
parent 03c1b24dea
commit 3d34aa7f01
3 changed files with 6 additions and 2 deletions

View file

@ -171,7 +171,7 @@ static void tst2() {
rational int64_max("9223372036854775807");
rational int64_min(-int64_max - rational(1));
rational int64_min((-int64_max) - rational(1));
// is_int64
SASSERT(int64_max.is_int64());
SASSERT(int64_min.is_int64());

View file

@ -128,6 +128,8 @@ mpz_manager<SYNCH>::mpz_manager():
mpz_mul(m_int64_max, m_tmp, m_int64_max);
mpz_set_ui(m_tmp, max_l);
mpz_add(m_int64_max, m_tmp, m_int64_max);
mpz_neg(m_int64_min, m_int64_max);
mpz_sub_ui(m_int64_min, m_int64_min, 1);
#endif
mpz one(1);
@ -152,6 +154,7 @@ mpz_manager<SYNCH>::~mpz_manager() {
deallocate(m_arg[1]);
mpz_clear(m_uint64_max);
mpz_clear(m_int64_max);
mpz_clear(m_int64_min);
#endif
if (SYNCH)
omp_destroy_nest_lock(&m_lock);
@ -1317,7 +1320,7 @@ bool mpz_manager<SYNCH>::is_int64(mpz const & a) const {
}
#else
// GMP version
return mpz_cmp(*a.m_ptr, m_int64_max) <= 0;
return mpz_cmp(m_int64_min, *a.m_ptr) <= 0 && mpz_cmp(*a.m_ptr, m_int64_max) <= 0;
#endif
}

View file

@ -168,6 +168,7 @@ class mpz_manager {
mpz_t * m_arg[2];
mpz_t m_uint64_max;
mpz_t m_int64_max;
mpz_t m_int64_min;
mpz_t * allocate() {
mpz_t * cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));