Skip to content

Commit d0190e1

Browse files
authored
Merge pull request #15191 from pgebal/smtchecker/fix-invalid-number-of-verified-checks
SMTChecker: Fix error that reports invalid number of verified checks
2 parents 7f25267 + 48f97a3 commit d0190e1

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
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

1212

1313
Bugfixes:
14+
* SMTChecker: Fix error that reports invalid number of verified checks for BMC engine.
1415
* TypeChecker: Fix segfault when assigning nested tuple to tuple.
1516
* Yul Optimizer: Name simplification could lead to forbidden identifiers with a leading and/or trailing dot, e.g., ``x._`` would get simplified into ``x.``.
1617

libsolidity/formal/BMC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,18 @@ void BMC::analyze(SourceUnit const& _source, std::map<ASTNode const*, std::set<V
118118
);
119119

120120
if (!m_settings.showProvedSafe && !m_safeTargets.empty())
121+
{
122+
std::size_t provedSafeNum = 0;
123+
for (auto&& [_, targets]: m_safeTargets)
124+
provedSafeNum += targets.size();
121125
m_errorReporter.info(
122126
6002_error,
123127
"BMC: " +
124-
std::to_string(m_safeTargets.size()) +
128+
std::to_string(provedSafeNum) +
125129
" verification condition(s) proved safe!" +
126130
" Enable the model checker option \"show proved safe\" to see all of them."
127131
);
132+
}
128133
else if (m_settings.showProvedSafe)
129134
for (auto const& [node, targets]: m_safeTargets)
130135
for (auto const& target: targets)

libsolidity/formal/BMC.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ class BMC: public SMTEncoder
149149

150150
friend bool operator<(BMCVerificationTarget const& _a, BMCVerificationTarget const& _b)
151151
{
152-
return _a.expression->id() < _b.expression->id();
152+
if (_a.expression->id() == _b.expression->id())
153+
return _a.type < _b.type;
154+
else
155+
return _a.expression->id() < _b.expression->id();
153156
}
154157
};
155158

test/libsolidity/smtCheckerTests/bmc_coverage/branches_with_return/constructor_state_variable_init.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ contract C is B {
3939
// Warning 4661: (389-412): BMC: Assertion violation happens here.
4040
// Warning 4661: (489-513): BMC: Assertion violation happens here.
4141
// Warning 4661: (533-546): BMC: Assertion violation happens here.
42-
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
42+
// Info 6002: BMC: 5 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/operators/unary_minus_bmc.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ contract C
88
// SMTEngine: bmc
99
// ----
1010
// Warning 4661: (48-63): BMC: Assertion violation happens here.
11-
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
11+
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/operators/userDefined/user_defined_operator_matches_equivalent_function_call.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ contract C {
7777
// Warning 4144: (953-982): BMC: Underflow (resulting value less than -32768) happens here.
7878
// Warning 3046: (1149-1178): BMC: Division by zero happens here.
7979
// Warning 7812: (2245-2271): BMC: Assertion violation might happen here.
80-
// Info 6002: BMC: 8 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
80+
// Info 6002: BMC: 10 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
contract C {
2+
function f(int x, int y) public pure returns (int) {
3+
require(x == 0);
4+
require(y == 0);
5+
return x + y;
6+
}
7+
}
8+
// ====
9+
// SMTEngine: bmc
10+
// ----
11+
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

0 commit comments

Comments
 (0)