bitset: fix implementation of operator-()

This fixes #469.

* spot/misc/bitset.hh (bitset::operator-): Rewrite.
I cannot follow the logic of the old implementation.
* tests/python/setacc.py: Add a test case, inspired from #469.
This commit is contained in:
Alexandre Duret-Lutz 2021-07-05 14:12:58 +02:00
parent 3d79022abb
commit b01bc62f52
2 changed files with 19 additions and 8 deletions

View file

@ -319,15 +319,12 @@ namespace spot
bitset operator-() const
{
bitset res = *this;
unsigned carry = 0;
unsigned carry = 1;
for (auto& v : res.data)
{
v += carry;
if (v < carry)
carry = 2;
else
carry = 1;
v = -v;
word_t old = v;
v = ~v + carry;
carry = old == 0;
}
return res;
}