3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-05 14:56:11 +00:00

fix build warnings

This commit is contained in:
Nikolaj Bjorner 2026-06-22 18:20:23 -07:00
parent 86737e11ea
commit cb3d058067
19 changed files with 22 additions and 29 deletions

View file

@ -175,7 +175,7 @@ static void test_ackr_bound_probe() {
// by the BV solver back to a model for the original formula (with UF).
// The two null-pointer guards in ackr_model_converter.cpp are exercised here.
//
static void test_ackermannize_bv_model() {
[[maybe_unused]] static void test_ackermannize_bv_model() {
Z3_config cfg = Z3_mk_config();
Z3_context ctx = Z3_mk_context(cfg);
Z3_del_config(cfg);

View file

@ -297,7 +297,7 @@ static void test_bug_translate_null_target() {
// Z3_translate(ctx, x, nullptr) would crash - no null check on target
// The function checks c == target (line 1517) but doesn't check target != nullptr first
// So mk_c(target) on line 1522 dereferences nullptr
Z3_error_code err = Z3_get_error_code(ctx);
Z3_get_error_code(ctx);
std::cout << " [BUG DOCUMENTED] Z3_translate(ctx, ast, nullptr) would crash\n";
std::cout << " No null check on target before mk_c(target) at api_ast.cpp:1522\n";
@ -596,7 +596,6 @@ static void test_bug_array_sort_mismatch() {
// Create Array(Int, Int)
Z3_sort int_sort = Z3_mk_int_sort(ctx);
Z3_sort bool_sort = Z3_mk_bool_sort(ctx);
Z3_sort arr_sort = Z3_mk_array_sort(ctx, int_sort, int_sort);
Z3_ast arr = Z3_mk_const(ctx, Z3_mk_string_symbol(ctx, "a"), arr_sort);
@ -651,7 +650,7 @@ static void test_bug_substitute_null_arrays() {
// With num_exprs=0, null arrays should be fine
Z3_ast r = Z3_substitute(ctx, x, 0, nullptr, nullptr);
Z3_error_code err = Z3_get_error_code(ctx);
Z3_get_error_code(ctx);
if (r != nullptr) {
std::cout << " substitute(x, 0, null, null) OK: " << Z3_ast_to_string(ctx, r) << "\n";
}

View file

@ -70,7 +70,7 @@ static void test_pop() {
TestNode* list = nullptr;
TestNode node1(1);
TestNode::push_to_front(list, &node1);
TestNode* popped = TestNode::pop(list);
[[maybe_unused]] TestNode* popped = TestNode::pop(list);
SASSERT(popped == &node1);
SASSERT(list == nullptr);
SASSERT(popped->next() == popped);

View file

@ -303,14 +303,13 @@ class test_doc_cls {
bool_vector to_merge(N, false);
bit_vector discard_cols;
discard_cols.resize(N, false);
unsigned num_bits = 1;
union_find_default_ctx union_ctx;
subset_ints equalities(union_ctx);
unsigned lo = N;
equalities.mk_var();
for (unsigned i = 1; i < N; ++i) {
to_merge[i] = (m_ran(2) == 0);
if (!to_merge[i]) ++num_bits; else lo = i;
if (to_merge[i]) lo = i;
equalities.mk_var();
}
if (lo == N) return;

View file

@ -38,7 +38,6 @@ int vals[N];
static void tst1() {
int_set h1;
int size = 0;
for (int i = 1; i < N; i ++) {
int v = rand() % (N / 2);
h1.insert(v);
@ -92,7 +91,7 @@ static void tst2() {
ENSURE(contains(h1, elem));
n++;
}
ENSURE(n == h1.size());
ENSURE(n == static_cast<int>(h1.size()));
}
ENSURE(h1.size() == h2.size());
// std::cout << "size: " << h1.size() << ", capacity: " << h1.capacity() << "\n"; std::cout.flush();
@ -194,7 +193,7 @@ void test_hashtable_iterators() {
ht.insert(3);
int count = 0;
for (const auto& elem : ht) {
for ([[maybe_unused]] const auto& elem : ht) {
++count;
}
VERIFY(count == 3);

View file

@ -119,7 +119,7 @@ expr_ref hilbert_basis_validate::mk_validate(hilbert_basis& hb) {
bool is_initial;
hb.get_basis_solution(i, v, is_initial);
for (unsigned j = 0; xs.size() < v.size(); ++j) {
for (; xs.size() < v.size(); ) {
xs.push_back(m.mk_fresh_const("x", a.mk_int()));
}

View file

@ -39,7 +39,7 @@ static void hit_me(char const* wm) {
Z3_mk_bv_sort(ctx,i);
}
catch (std::bad_alloc) {
catch (const std::bad_alloc&) {
std::cout << "caught\n";
}
}

View file

@ -81,12 +81,12 @@ void tst_model_evaluator() {
SASSERT(fi2.num_entries() == 1);
expr_ref removed_arg(a.mk_int(0), m);
expr* removed_args[1] = { removed_arg.get() };
[[maybe_unused]] expr* removed_args[1] = { removed_arg.get() };
SASSERT(fi2.get_entry(removed_args) == nullptr);
expr_ref kept_arg(a.mk_int(599), m);
expr* kept_args[1] = { kept_arg.get() };
func_entry* kept = fi2.get_entry(kept_args);
[[maybe_unused]] func_entry* kept = fi2.get_entry(kept_args);
SASSERT(kept != nullptr);
SASSERT(kept->get_result() == one.get());
}

View file

@ -73,7 +73,7 @@ static void tst2() {
m.enable_concurrent(true);
vector<std::pair<cell *, int> > object_coeff_pairs;
unsigned num_resets = 0;
[[maybe_unused]] unsigned num_resets = 0;
for (unsigned i = 0; i < 100000; ++i) {
unsigned idx = rand() % 6;

View file

@ -76,9 +76,9 @@ static void test_polymorphic_datatype_api() {
std::cout << "triple_int_bool: " << Z3_sort_to_string(ctx, triple_int_bool) << "\n";
// Get constructors and accessors from the instantiated datatype
Z3_func_decl mk_triple_int_bool = Z3_get_datatype_sort_constructor(ctx, triple_int_bool, 0);
[[maybe_unused]] Z3_func_decl mk_triple_int_bool = Z3_get_datatype_sort_constructor(ctx, triple_int_bool, 0);
Z3_func_decl first_int_bool = Z3_get_datatype_sort_constructor_accessor(ctx, triple_int_bool, 0, 0);
Z3_func_decl second_int_bool = Z3_get_datatype_sort_constructor_accessor(ctx, triple_int_bool, 0, 1);
[[maybe_unused]] Z3_func_decl second_int_bool = Z3_get_datatype_sort_constructor_accessor(ctx, triple_int_bool, 0, 1);
Z3_func_decl third_int_bool = Z3_get_datatype_sort_constructor_accessor(ctx, triple_int_bool, 0, 2);
std::cout << "Got constructors and accessors from instantiated datatype\n";

View file

@ -199,7 +199,7 @@ struct test_seq {
ptr_vector<expr> const& lhs(expr* eq) {
auto& ev = get_eval(eq);
if (ev.lhs.empty()) {
expr* x, * y;
expr* x = nullptr, * y = nullptr;
VERIFY(m.is_eq(eq, x, y));
seq.str.get_concat(x, ev.lhs);
seq.str.get_concat(y, ev.rhs);

View file

@ -239,7 +239,7 @@ namespace bv {
}
static void test_eval1() {
[[maybe_unused]] static void test_eval1() {
ast_manager m;
reg_decl_plugins(m);
bv_util bv(m);
@ -262,7 +262,7 @@ static void test_eval1() {
}
}
static void test_repair1() {
[[maybe_unused]] static void test_repair1() {
ast_manager m;
reg_decl_plugins(m);
bv_util bv(m);