3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-14 18:06:15 +00:00

fix assorted undefined behaviors caught by clang

Signed-off-by: Nuno Lopes <nlopes@microsoft.com>
This commit is contained in:
Nuno Lopes 2015-05-23 11:45:12 +01:00
parent 25a29bf5b0
commit c577ab361b
9 changed files with 81 additions and 21 deletions

View file

@ -29,9 +29,9 @@ rational rational::m_one;
rational rational::m_minus_one;
vector<rational> rational::m_powers_of_two;
void mk_power_up_to(vector<rational> & pws, unsigned n) {
static void mk_power_up_to(vector<rational> & pws, unsigned n) {
if (pws.empty()) {
pws.push_back(rational(1));
pws.push_back(rational::one());
}
unsigned sz = pws.size();
rational curr = pws[sz - 1];
@ -53,16 +53,28 @@ rational rational::power_of_two(unsigned k) {
return result;
}
// in inf_rational.cpp
void initialize_inf_rational();
void finalize_inf_rational();
// in inf_int_rational.cpp
void initialize_inf_int_rational();
void finalize_inf_int_rational();
void rational::initialize() {
if (!g_mpq_manager) {
g_mpq_manager = alloc(synch_mpq_manager);
m().set(m_zero.m_val, 0);
m().set(m_one.m_val, 1);
m().set(m_minus_one.m_val, -1);
initialize_inf_rational();
initialize_inf_int_rational();
}
}
void rational::finalize() {
finalize_inf_rational();
finalize_inf_int_rational();
m_powers_of_two.finalize();
m_zero.~rational();
m_one.~rational();