Skip to content

Commit fc45ba0

Browse files
authored
Merge pull request #15705 from ethereum/smt-fix-translation
SMTChecker: Fix parsing of array select and store expressions
2 parents 85ee2bd + ded4c98 commit fc45ba0

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Compiler Features:
1111
Bugfixes:
1212
* General: Fix internal compiler error when requesting IR AST outputs for interfaces and abstract contracts.
1313
* SMTChecker: Fix SMT logic error when initializing a fixed-sized-bytes array using string literals.
14+
* SMTChecker: Fix SMT logic error when translating invariants involving array store and select operations.
1415
* Standard JSON Interface: Fix ``generatedSources`` and ``sourceMap`` being generated internally even when not requested.
1516
* Yul: Fix internal compiler error when a code generation error should be reported instead.
1617

libsmtutil/CHCSmtLib2Interface.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,16 @@ smtutil::Expression CHCSmtLib2Interface::ScopedParser::toSMTUtilExpression(SMTLi
355355
auto accessor = maybeTupleAccessor.value();
356356
return smtutil::Expression("dt_accessor_" + accessor.first, std::move(arguments), accessor.second);
357357
}
358+
if (op == "select")
359+
{
360+
smtSolverInteractionRequire(arguments.size() == 2, "Select has two arguments: array and index");
361+
return smtutil::Expression::select(arguments[0], arguments[1]);
362+
}
363+
if (op == "store")
364+
{
365+
smtSolverInteractionRequire(arguments.size() == 3, "Store has three arguments: array, index and element");
366+
return smtutil::Expression::store(arguments[0], arguments[1], arguments[2]);
367+
}
358368
else
359369
{
360370
std::set<std::string> boolOperators{"and", "or", "not", "=", "<", ">", "<=", ">=", "=>"};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
contract C {
2+
constructor() {
3+
int8 v;
4+
(v *= v);
5+
}
6+
}
7+
8+
contract D {
9+
bool[2] internal a;
10+
11+
function f() internal view {
12+
do {} while(!(a[1]));
13+
}
14+
}
15+
// ====
16+
// SMTEngine: chc
17+
// SMTIgnoreInv: no
18+
// SMTSolvers: z3
19+
// SMTTargets: overflow
20+
// ----
21+
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
22+
// Info 1180: Contract invariant(s) for :D:\n(true || true)\nReentrancy property(ies) for :C:\n((<errorCode> = 0) && (x!5 = x!4))\nReentrancy property(ies) for :D:\n((<errorCode> = 0) && (x!6 = x!4) && (a' = a))\n<errorCode> = 0 -> no errors\n<errorCode> = 1 -> Overflow at v *= v\n

0 commit comments

Comments
 (0)