From e9b4f069728b23b73017bdd1119f9d7063b5dd53 Mon Sep 17 00:00:00 2001 From: Mavo Date: Fri, 26 Feb 2016 13:05:16 +0100 Subject: [PATCH] Better assertions in BitVector Former-commit-id: 7ee6b34ba5bced25fca9e1702e32a451e69f7d30 --- src/storage/BitVector.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/BitVector.cpp b/src/storage/BitVector.cpp index cd5f46009..ddfcb9de9 100644 --- a/src/storage/BitVector.cpp +++ b/src/storage/BitVector.cpp @@ -412,6 +412,7 @@ namespace storm { } uint_fast64_t BitVector::getAsInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits) const { + STORM_LOG_ASSERT(numberOfBits <= 64, "Number of bits must be <= 64."); uint64_t bucket = bitIndex >> 6; uint64_t bitIndexInBucket = bitIndex & mod64mask; @@ -451,7 +452,8 @@ namespace storm { } void BitVector::setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value) { - STORM_LOG_ASSERT((value >> numberOfBits) == 0, "Integer value too large to fit in the given number of bits."); + STORM_LOG_ASSERT(numberOfBits <= 64, "Number of bits must be <= 64."); + STORM_LOG_ASSERT(numberOfBits == 64 || (value >> numberOfBits) == 0, "Integer value too large to fit in the given number of bits."); uint64_t bucket = bitIndex >> 6; uint64_t bitIndexInBucket = bitIndex & mod64mask; @@ -692,4 +694,4 @@ namespace std { std::size_t hash::operator()(storm::storage::BitVector const& bv) const { return boost::hash_range(bv.bucketVector.begin(), bv.bucketVector.end()); } -} \ No newline at end of file +}