From a9293f329e3e3a5a3a5503cd429dd93facf2ccd4 Mon Sep 17 00:00:00 2001 From: Maximilien Colange Date: Fri, 25 May 2018 14:09:47 +0200 Subject: [PATCH] fix warnings when compiling without assertions * spot/twa/acc.hh, spot/twaalgos/alternation.cc, spot/twaalgos/determinize.cc, spot/twaalgos/ndfs_result.hxx, spot/twaalgos/tau03.cc, spot/ltsmin/ltsmin.cc, tests/core/parity.cc: here --- spot/ltsmin/ltsmin.cc | 8 +++--- spot/twa/acc.hh | 2 ++ spot/twaalgos/alternation.cc | 3 +-- spot/twaalgos/determinize.cc | 2 +- spot/twaalgos/ndfs_result.hxx | 2 +- spot/twaalgos/tau03.cc | 2 +- tests/core/parity.cc | 46 ++++++++++++++++++----------------- 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/spot/ltsmin/ltsmin.cc b/spot/ltsmin/ltsmin.cc index d984650e8..fda07abaf 100644 --- a/spot/ltsmin/ltsmin.cc +++ b/spot/ltsmin/ltsmin.cc @@ -234,7 +234,7 @@ namespace spot fixed_size_pool* p = static_cast(ctx->pool); spins_state* out = new(p->allocate()) spins_state(ctx->state_size, p); - assert(out != nullptr); + SPOT_ASSUME(out != nullptr); memcpy(out->vars, dst, ctx->state_size * sizeof(int)); out->compute_hash(); ctx->transitions.emplace_back(out); @@ -252,7 +252,7 @@ namespace spot - sizeof(spins_compressed_state::vars) + sizeof(int) * csize); spins_compressed_state* out = new(mem) spins_compressed_state(csize, p); - assert(out != nullptr); + SPOT_ASSUME(out != nullptr); memcpy(out->vars, ctx->compressed, csize * sizeof(int)); out->compute_hash(); ctx->transitions.emplace_back(out); @@ -713,7 +713,7 @@ namespace spot + sizeof(int) * csize); spins_compressed_state* res = new(mem) spins_compressed_state(csize, p); - assert(res != nullptr); + SPOT_ASSUME(res != nullptr); memcpy(res->vars, compressed_, csize * sizeof(int)); res->compute_hash(); return res; @@ -722,7 +722,7 @@ namespace spot { fixed_size_pool* p = const_cast(&statepool_); spins_state* res = new(p->allocate()) spins_state(state_size_, p); - assert(res != nullptr); + SPOT_ASSUME(res != nullptr); d_->get_initial_state(res->vars); res->compute_hash(); return res; diff --git a/spot/twa/acc.hh b/spot/twa/acc.hh index d0c2e4c5c..b3e35b75f 100644 --- a/spot/twa/acc.hh +++ b/spot/twa/acc.hh @@ -109,6 +109,7 @@ namespace spot bool operator==(unsigned o) const { SPOT_ASSERT(o == 0U); + (void)o; return !id; } @@ -116,6 +117,7 @@ namespace spot bool operator!=(unsigned o) const { SPOT_ASSERT(o == 0U); + (void)o; return !!id; } diff --git a/spot/twaalgos/alternation.cc b/spot/twaalgos/alternation.cc index 63a7745cd..848a318b2 100644 --- a/spot/twaalgos/alternation.cc +++ b/spot/twaalgos/alternation.cc @@ -158,8 +158,7 @@ namespace spot assert(si_.is_accepting_scc(n)); // Catch unsupported types of automata - bool rej = ensure_weak_scc(n); - assert(rej == false); + assert(!ensure_weak_scc(n)); // Detect if it is a "true state" unsigned s = si_.states_of(n).front(); auto& ss = g.state_storage(s); diff --git a/spot/twaalgos/determinize.cc b/spot/twaalgos/determinize.cc index f6b418b17..92cfc65e0 100644 --- a/spot/twaalgos/determinize.cc +++ b/spot/twaalgos/determinize.cc @@ -360,7 +360,7 @@ namespace spot { path.emplace_back(std::move(ss)); auto i = states.insert(path.back()); - assert(i.second); + SPOT_ASSUME(i.second); ss = path.back().compute_succ(cs_, ap, color_); mincolor = std::min(color_, mincolor); stop = states.find(ss) != states.end(); diff --git a/spot/twaalgos/ndfs_result.hxx b/spot/twaalgos/ndfs_result.hxx index 9d9878fc0..a0a3c49f0 100644 --- a/spot/twaalgos/ndfs_result.hxx +++ b/spot/twaalgos/ndfs_result.hxx @@ -649,7 +649,7 @@ namespace spot // This initial state is outside the cycle. Compute the prefix. min_path s(this, a_, target, h_); cycle_entry_point = s.search(prefix_start, run->prefix); - SPOT_ASSERT(cycle_entry_point); + SPOT_ASSUME(cycle_entry_point); cycle_entry_point = cycle_entry_point->clone(); } diff --git a/spot/twaalgos/tau03.cc b/spot/twaalgos/tau03.cc index 059e14eda..61e041776 100644 --- a/spot/twaalgos/tau03.cc +++ b/spot/twaalgos/tau03.cc @@ -299,7 +299,7 @@ namespace spot } acc_cond::mark_t get_acc() const { - assert(!is_white()); + SPOT_ASSUME(!is_white()); return *acc; } void cumulate_acc(acc_cond::mark_t a) diff --git a/tests/core/parity.cc b/tests/core/parity.cc index d9a453ba2..89a24e724 100644 --- a/tests/core/parity.cc +++ b/tests/core/parity.cc @@ -18,7 +18,6 @@ // along with this program. If not, see . #include "config.h" -#include #include #include #include @@ -344,43 +343,46 @@ int main() for (auto style: parity_styles) { auto output = spot::change_parity(aut, kind, style); - assert(is_right_parity(output, kind, style, - is_max, is_odd, acc_num_sets) - && "change_parity: wrong acceptance."); - assert(are_equiv(aut, output) - && "change_parity: not equivalent."); - assert(is_almost_colored(output) - && "change_parity: too many acc on a transition"); + + if (!is_right_parity(output, kind, style, + is_max, is_odd, acc_num_sets)) + throw std::runtime_error("change parity: wrong acceptance"); + if (!are_equiv(aut, output)) + throw std::runtime_error("change_parity: not equivalent."); + if (!is_almost_colored(output)) + throw std::runtime_error( + "change_parity: too many acc on a transition"); } // Check colorize_parity for (auto keep_style: { true, false }) { auto output = spot::colorize_parity(aut, keep_style); - assert(is_colored_printerr(output) - && "colorize_parity: not colored."); - assert(are_equiv(aut, output) - && "colorize_parity: not equivalent."); + if (!is_colored_printerr(output)) + throw std::runtime_error("colorize_parity: not colored."); + if (!are_equiv(aut, output)) + throw std::runtime_error("colorize_parity: not equivalent."); auto target_kind = to_parity_kind(is_max); auto target_style = keep_style ? to_parity_style(is_odd) : spot::parity_style_any; - assert(is_right_parity(output, target_kind, target_style, - is_max, is_odd, acc_num_sets) - && "change_parity: wrong acceptance."); + if (!is_right_parity(output, target_kind, target_style, + is_max, is_odd, acc_num_sets)) + throw std::runtime_error("change_parity: wrong acceptance."); } // Check cleanup_parity for (auto keep_style: { true, false }) { auto output = spot::cleanup_parity(aut, keep_style); - assert(is_almost_colored(output) - && "cleanup_parity: too many acc on a transition."); - assert(are_equiv(aut, output) - && "cleanup_parity: not equivalent."); + if (!is_almost_colored(output)) + throw std::runtime_error( + "cleanup_parity: too many acc on a transition."); + if (!are_equiv(aut, output)) + throw std::runtime_error("cleanup_parity: not equivalent."); auto target_kind = to_parity_kind(is_max); auto target_style = keep_style ? to_parity_style(is_odd) : spot::parity_style_any; - assert(is_right_parity(output, target_kind, target_style, - is_max, is_odd, acc_num_sets) - && "cleanup_parity: wrong acceptance."); + if (!is_right_parity(output, target_kind, target_style, + is_max, is_odd, acc_num_sets)) + throw std::runtime_error("cleanup_parity: wrong acceptance."); } } }