diff options
author | makaimann <makaim@stanford.edu> | 2019-10-18 11:42:15 -0700 |
---|---|---|
committer | Aina Niemetz <aina.niemetz@gmail.com> | 2019-10-18 11:42:15 -0700 |
commit | ba175a951064250907494b7b5112f3882889df5e (patch) | |
tree | 2d60d81e0696a6774014ee83b7ea7bdde4dede84 /src | |
parent | 5396f014b66cbfd7cc16380c05c1539b1efe583c (diff) |
Update overflow check to handle negative numbers (#3396)
Diffstat (limited to 'src')
-rw-r--r-- | src/api/cvc4cpp.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/api/cvc4cpp.cpp b/src/api/cvc4cpp.cpp index d1112a9dc..aed443197 100644 --- a/src/api/cvc4cpp.cpp +++ b/src/api/cvc4cpp.cpp @@ -2023,9 +2023,19 @@ Term Solver::mkBVFromStrHelper(uint32_t size, << "base 2, 10, or 16"; Integer val(s, base); - CVC4_API_CHECK(val.modByPow2(size) == val) - << "Overflow in bitvector construction (specified bitvector size " << size - << " too small to hold value " << s << ")"; + + if (val.strictlyNegative()) + { + CVC4_API_CHECK(val >= -Integer("2", 10).pow(size - 1)) + << "Overflow in bitvector construction (specified bitvector size " + << size << " too small to hold value " << s << ")"; + } + else + { + CVC4_API_CHECK(val.modByPow2(size) == val) + << "Overflow in bitvector construction (specified bitvector size " + << size << " too small to hold value " << s << ")"; + } return mkValHelper<CVC4::BitVector>(CVC4::BitVector(size, val)); } |