fix and check shifting issue

The exception raised by << and >> when shifting mark_t by too many
bits are only enabled in SPOT_DEBUG, as those operations are quite
low-level.  However we were always testing them, and although we
wanted them to be active in Python, it was not always the case.

* spot/twa/acc.hh: introduce max_accsets() as
a static constexpr method, so we can see it in Python.
* spot/misc/bitset.hh: Fix preprocessing directive
so the check is actually enabled when compiling the Python
bindings.
* bin/autcross.cc, bin/autfilt.cc, bin/ltlcross.cc: Use max_accsets().
* tests/core/acc.cc: Comment out the shifting exception when
SPOT_DEBUG is unset.
* tests/python/except.py: Make sure the exception is always raised in
Python.
This commit is contained in:
Alexandre Duret-Lutz 2018-05-25 11:29:59 +02:00
parent 23e0d718fd
commit b12eb0508f
7 changed files with 75 additions and 38 deletions

View file

@ -509,7 +509,8 @@ namespace
const spot::const_twa_graph_ptr& aut_j,
size_t i, size_t j)
{
if (aut_i->num_sets() + aut_j->num_sets() > SPOT_MAX_ACCSETS)
if (aut_i->num_sets() + aut_j->num_sets() >
spot::acc_cond::mark_t::max_accsets())
{
std::cerr << "info: building " << autname(i)
<< '*' << autname(j, true)

View file

@ -649,7 +649,8 @@ static spot::twa_graph_ptr
product(spot::twa_graph_ptr left, spot::twa_graph_ptr right)
{
if ((type == spot::postprocessor::BA)
&& (left->num_sets() + right->num_sets() > SPOT_MAX_ACCSETS))
&& (left->num_sets() + right->num_sets() >
spot::acc_cond::mark_t::max_accsets()))
{
left = ensure_tba(left);
right = ensure_tba(right);
@ -661,7 +662,8 @@ static spot::twa_graph_ptr
product_or(spot::twa_graph_ptr left, spot::twa_graph_ptr right)
{
if ((type == spot::postprocessor::BA)
&& (left->num_sets() + right->num_sets() > SPOT_MAX_ACCSETS))
&& (left->num_sets() + right->num_sets() >
spot::acc_cond::mark_t::max_accsets()))
{
left = ensure_tba(left);
right = ensure_tba(right);
@ -965,7 +967,8 @@ parse_opt(int key, char* arg, struct argp_state*)
if (res < 0)
error(2, 0, "acceptance sets should be non-negative:"
" --mask-acc=%ld", res);
if (static_cast<unsigned long>(res) > SPOT_MAX_ACCSETS)
if (static_cast<unsigned long>(res) >=
spot::acc_cond::mark_t::max_accsets())
error(2, 0, "this implementation does not support that many"
" acceptance sets: --mask-acc=%ld", res);
opt_mask_acc.set(res);

View file

@ -691,7 +691,8 @@ namespace
const spot::const_twa_graph_ptr& aut_j,
size_t i, size_t j, bool icomp, bool jcomp)
{
if (aut_i->num_sets() + aut_j->num_sets() > SPOT_MAX_ACCSETS)
if (aut_i->num_sets() + aut_j->num_sets() >
spot::acc_cond::mark_t::max_accsets())
{
// Report the skipped test if both automata are not
// complemented, or the --verbose option is used,