forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsafe_assert_false_positive.sol
32 lines (27 loc) · 1.06 KB
/
safe_assert_false_positive.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
contract C {
uint x;
uint y;
function g(uint _x) public {
f1(_x);
// If the body of function `f` is ignored while keeping the state,
// the assertion is true and not reporting it would be a false negative.
// However, since `f` can change the state, the state variables are also
// assigned nondeterministic values after a call to `f`.
// Therefore the assertion below should fail.
assert(x == 0);
f2(_x);
assert(y == 0); // should fail
}
/// @custom:smtchecker abstract-function-nondet
function f1(uint _x) internal {
x = _x;
}
function f2(uint _y) internal {
y = _y;
}
}
// ====
// SMTEngine: chc
// ----
// Warning 6328: (400-414): CHC: Assertion violation happens here.\nCounterexample:\nx = 1, y = 0\n_x = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, y = 0\nC.g(0)\n C.f1(0) -- internal call
// Warning 6328: (429-443): CHC: Assertion violation happens here.\nCounterexample:\nx = 1, y = 1\n_x = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0, y = 0\nC.g(1)\n C.f1(1) -- internal call\n C.f2(1) -- internal call