Skip to content

Commit 718f392

Browse files
author
Leo Alt
committed
Don't erase things for BMC if function call is staticcall
1 parent a55685c commit 718f392

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

libsolidity/formal/BMC.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ void BMC::internalOrExternalFunctionCall(FunctionCall const& _funCall)
587587
_funCall.location(),
588588
"BMC does not yet implement this type of function call."
589589
);
590+
else if (funType.kind() == FunctionType::Kind::BareStaticCall)
591+
{
592+
// Do nothing here.
593+
// Neither storage nor balances should be modified.
594+
}
590595
else
591596
{
592597
m_externalFunctionCallHappened = true;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f(address _a) public {
3+
uint b1 = address(this).balance;
4+
_a.call("");
5+
uint b2 = address(this).balance;
6+
assert(b1 == b2); // should fail
7+
}
8+
}
9+
// ====
10+
// SMTEngine: bmc
11+
// ----
12+
// Warning 9302: (83-94): Return value of low-level calls not used.
13+
// Warning 4661: (133-149): BMC: Assertion violation happens here.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
uint x;
3+
function f(address _a) public {
4+
x = 2;
5+
_a.call("");
6+
assert(x == 2); // should fail
7+
}
8+
}
9+
// ====
10+
// SMTEngine: bmc
11+
// ----
12+
// Warning 9302: (66-77): Return value of low-level calls not used.
13+
// Warning 4661: (81-95): BMC: Assertion violation happens here.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract C {
2+
function f(address _a) public view {
3+
uint b1 = address(this).balance;
4+
_a.staticcall("");
5+
uint b2 = address(this).balance;
6+
assert(b1 == b2); // should hold
7+
}
8+
}
9+
// ====
10+
// SMTEngine: bmc
11+
// ----
12+
// Warning 9302: (88-105): Return value of low-level calls not used.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract C {
2+
uint x;
3+
function f(address _a) public {
4+
x = 2;
5+
_a.staticcall("");
6+
assert(x == 2); // should hold
7+
}
8+
}
9+
// ====
10+
// SMTEngine: bmc
11+
// ----
12+
// Warning 9302: (66-83): Return value of low-level calls not used.

0 commit comments

Comments
 (0)