Skip to content

Commit 126e818

Browse files
author
BaierD
committed
Improve default type sizes check error msg for fromIeeeBitvector() and add more info about CVC5 exception for the same method
1 parent 54ebac4 commit 126e818

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/org/sosy_lab/java_smt/basicimpl/AbstractFloatingPointFormulaManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.math.BigInteger;
1616
import java.util.HashMap;
1717
import java.util.Map;
18+
import org.sosy_lab.common.MoreStrings;
1819
import org.sosy_lab.common.rationals.Rational;
1920
import org.sosy_lab.java_smt.api.BitvectorFormula;
2021
import org.sosy_lab.java_smt.api.BooleanFormula;
@@ -249,8 +250,12 @@ public FloatingPointFormula fromIeeeBitvector(
249250
BitvectorType bvType = (BitvectorType) formulaCreator.getFormulaType(pNumber);
250251
Preconditions.checkArgument(
251252
bvType.getSize() == pTargetType.getTotalSize(),
252-
"The total size of the used FloatingPointType has to match the size of the bitvector"
253-
+ " given");
253+
MoreStrings.lazyString(
254+
() ->
255+
String.format(
256+
"The total size of the used FloatingPointType %s has to match the size of "
257+
+ "the bitvector argument %s",
258+
pTargetType.getTotalSize(), bvType.getSize())));
254259
return wrap(fromIeeeBitvectorImpl(extractInfo(pNumber), pTargetType));
255260
}
256261

src/org/sosy_lab/java_smt/solvers/cvc5/CVC5FloatingPointFormulaManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ protected Term fromIeeeBitvectorImpl(Term pBitvector, FloatingPointType pTargetT
417417
pTargetType.getMantissaSize() + 1), // add sign bit
418418
pBitvector);
419419
} catch (CVC5ApiException cvc5ApiException) {
420-
// This seems to only be thrown for wrong exponent and mantissa sizes
420+
// This seems to only be thrown for wrong exponent and mantissa sizes (e.g. negative
421+
// numbers, size not equal to BV size etc.). We check for this beforehand, so this should
422+
// not be thrown.
421423
throw new RuntimeException(cvc5ApiException);
422424
}
423425
}

0 commit comments

Comments
 (0)