[SMTChecker] Support check/unchecked

This commit is contained in:
Leonardo Alt
2020-12-30 12:14:30 +01:00
parent eb05826857
commit 78d55e6b4a
74 changed files with 765 additions and 614 deletions
@@ -10,4 +10,3 @@ contract C {
}
}
// ----
// Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -11,5 +11,4 @@ contract C {
}
}
// ----
// Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 2529: (150-157): CHC: Empty array "pop" happens here.\nCounterexample:\na = []\nl = 0\n\n\nTransaction trace:\nconstructor()\nState: a = []\nf(0)
@@ -26,5 +26,4 @@ contract C {
}
}
// ----
// Warning 6328: (570-625): CHC: Assertion violation might happen here.
// Warning 4661: (570-625): BMC: Assertion violation happens here.
// Warning 6328: (570-625): CHC: Assertion violation happens here.\nCounterexample:\nc = [[[2]]]\n\n\n\nTransaction trace:\nconstructor()\nState: c = []\ng()
@@ -12,4 +12,3 @@ contract C {
}
}
// ----
// Warning 4984: (174-177): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -1,7 +1,5 @@
pragma experimental SMTChecker;
contract C {
uint z = 1;
uint w = z - 3;
function a(uint x, uint y) public pure returns (uint) {
return x + y;
}
@@ -18,8 +16,7 @@ contract C {
// ====
// SMTEngine: bmc
// ----
// Warning 2661: (141-146): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4144: (217-222): BMC: Underflow (resulting value less than 0) happens here.
// Warning 2661: (293-298): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 3046: (369-374): BMC: Division by zero happens here.
// Warning 4144: (68-73): BMC: Underflow (resulting value less than 0) happens here.
// Warning 2661: (111-116): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4144: (187-192): BMC: Underflow (resulting value less than 0) happens here.
// Warning 2661: (263-268): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 3046: (339-344): BMC: Division by zero happens here.
@@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
uint z = 1;
uint w = z - 3;
}
// ====
// SMTEngine: bmc
// ----
// Warning 4144: (68-73): BMC: Underflow (resulting value less than 0) happens here.
@@ -34,4 +34,4 @@ contract C {
}
}
// ----
// Warning 6328: (528-565): CHC: Assertion violation happens here.\nCounterexample:\nowner = (- 1), y = 0, z = 0, s = 0\n\n\n\nTransaction trace:\nconstructor()\nState: owner = (- 1), y = 0, z = 0, s = 0\nf()
// Warning 6328: (528-565): CHC: Assertion violation happens here.\nCounterexample:\nowner = 1, y = 0, z = 0, s = 0\n\n\n\nTransaction trace:\nconstructor()\nState: owner = 1, y = 0, z = 0, s = 0\nf()
@@ -17,5 +17,3 @@ contract C {
}
}
// ----
// Warning 6328: (200-214): CHC: Assertion violation might happen here.
// Warning 4661: (200-214): BMC: Assertion violation happens here.
@@ -21,6 +21,5 @@ contract A is B {
// ====
// SMTIgnoreCex: yes
// ----
// Warning 4984: (244-249): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (232-250): CHC: Assertion violation happens here.
// Warning 4984: (203-208): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -18,6 +18,5 @@ contract A is B {
}
}
// ----
// Warning 4984: (230-235): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 0\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\nTransaction trace:\nconstructor(115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Warning 4984: (207-212): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 0\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\nTransaction trace:\nconstructor(115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Warning 4984: (198-203): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 0\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\nTransaction trace:\nconstructor(115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Warning 4984: (198-203): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 0\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639934\n\n\nTransaction trace:\nconstructor(115792089237316195423570985008687907853269984665640564039457584007913129639934)
@@ -28,5 +28,4 @@ contract A is B2, B1 {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (200-205): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (314-319): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (302-320): CHC: Assertion violation happens here.
@@ -28,5 +28,4 @@ contract A is B2, B1 {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (200-205): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (314-319): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (302-320): CHC: Assertion violation happens here.
@@ -13,4 +13,4 @@ contract C {
}
}
// ----
// Warning 6328: (145-159): CHC: Assertion violation happens here.\nCounterexample:\nx = 10\ny = 9\n\n\nTransaction trace:\nconstructor()\nState: x = 10\nf(9)
// Warning 6328: (145-159): CHC: Assertion violation happens here.\nCounterexample:\nx = 10\ny = 11\n\n\nTransaction trace:\nconstructor()\nState: x = 10\nf(11)
@@ -14,5 +14,7 @@ contract C is B {
assert(y == x);
}
}
// ====
// SMTIgnoreCex: yes
// ----
// Warning 6328: (165-179): CHC: Assertion violation happens here.\nCounterexample:\nx = 10\ny = 11\n\n\nTransaction trace:\nconstructor()\nState: x = 10\nf(11)
// Warning 6328: (165-179): CHC: Assertion violation happens here.
@@ -17,4 +17,4 @@ contract C {
}
}
// ----
// Warning 6328: (293-307): CHC: Assertion violation happens here.
// Warning 6328: (293-307): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
@@ -21,4 +21,3 @@ contract C {
// ----
// Warning 6328: (136-155): CHC: Assertion violation happens here.\nCounterexample:\nTON = 1000\n\n\n\nTransaction trace:\nconstructor()\nState: TON = 1000\nf1()
// Warning 4984: (229-234): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\nTransaction trace:\nconstructor()\nf(115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Warning 4984: (327-332): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\nTransaction trace:\nconstructor()\nf(115792089237316195423570985008687907853269984665640564039457584007913129639935)
@@ -19,7 +19,7 @@ contract Der is Base {
}
// ----
// Warning 4984: (der:101-109): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (der:113-126): CHC: Assertion violation happens here.\nCounterexample:\nx = 3, a = 0\ny = 0\n\n\nTransaction trace:\nconstructor()\nState: x = 0, a = 0\ng(0)
// Warning 6328: (der:113-126): CHC: Assertion violation happens here.\nCounterexample:\nx = 3, a = 7\ny = 0\n\n\nTransaction trace:\nconstructor()\nState: x = 0, a = 0\ng(0)
// Warning 4984: (base:100-103): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 2661: (der:101-109): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -33,5 +33,4 @@ contract C is Z, B {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (138-145): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (366-371): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (394-408): CHC: Assertion violation happens here.
@@ -33,5 +33,4 @@ contract C is Z, B {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (138-145): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (366-371): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (394-408): CHC: Assertion violation happens here.
@@ -24,9 +24,5 @@ contract A is B {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (157-162): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (239-244): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (261-266): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (261-270): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (287-292): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (275-293): CHC: Assertion violation happens here.
// Warning 4984: (216-221): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -24,8 +24,5 @@ contract A is B {
// SMTIgnoreCex: yes
// ----
// Warning 4984: (157-163): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (240-245): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (262-268): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (285-290): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 6328: (273-291): CHC: Assertion violation happens here.
// Warning 4984: (217-222): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -12,4 +12,3 @@ contract Simple {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (132-135): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -10,4 +10,3 @@ contract Simple {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (116-119): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -9,9 +9,8 @@ contract Simple {
for (x = 0; x < 10; ++x) {}
assert(x == 10);
}
assert(y == x);
// Disabled because of Spacer nondeterminism.
//assert(y == x);
}
}
// ----
// Warning 6328: (187-201): CHC: Assertion violation might happen here.
// Warning 4661: (187-201): BMC: Assertion violation happens here.
@@ -21,5 +21,3 @@ contract LoopFor2 {
// SMTIgnoreCex: yes
// ----
// Warning 2072: (156-171): Unused local variable.
// Warning 4984: (252-257): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (232-238): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -20,5 +20,3 @@ contract LoopFor2 {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (245-250): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (225-231): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -20,4 +20,3 @@ contract LoopFor2 {
}
}
// ----
// Warning 4984: (311-317): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -24,5 +24,3 @@ contract LoopFor2 {
// SMTSolvers: z3
// ----
// Warning 2072: (156-171): Unused local variable.
// Warning 4984: (244-249): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (270-273): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -25,5 +25,3 @@ contract LoopFor2 {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (237-242): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (263-266): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -20,7 +20,5 @@ contract LoopFor2 {
}
}
// ----
// Warning 4984: (229-234): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (255-258): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (338-357): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
// Warning 6328: (361-380): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
@@ -13,7 +13,7 @@ contract C
function f() m public {
assert(x > 0);
x = x + 1;
unchecked { x = x + 1; }
}
function g(uint _x) public {
@@ -21,5 +21,4 @@ contract C
}
}
// ----
// Warning 4984: (203-208): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\nx = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ng(115792089237316195423570985008687907853269984665640564039457584007913129639935)\nState: x = 115792089237316195423570985008687907853269984665640564039457584007913129639935\nf()
// Warning 6328: (136-149): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ng(115792089237316195423570985008687907853269984665640564039457584007913129639935)\nState: x = 115792089237316195423570985008687907853269984665640564039457584007913129639935\nf()
@@ -12,4 +12,4 @@ contract C
}
}
// ----
// Warning 6328: (198-218): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\np = 0\n\n\nTransaction trace:\nconstructor()\nf(0, 0)
// Warning 6328: (198-218): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\np = 38\n\n\nTransaction trace:\nconstructor()\nf(0, 38)
@@ -12,4 +12,4 @@ contract C
}
}
// ----
// Warning 6328: (197-216): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\np = 0\n\n\nTransaction trace:\nconstructor()\nf(0, 0)
// Warning 6328: (197-216): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\np = 38\n\n\nTransaction trace:\nconstructor()\nf(0, 38)
@@ -4,12 +4,17 @@ contract C {
uint a;
bool b;
constructor(bool _b) {
b = _b;
}
function f() public returns(uint c) {
c = b ? a + 1 : a--;
assert(c > a);
c = b ? a + 10 : ++a;
assert(c >= a);
}
}
// ----
// Warning 4984: (129-134): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()\nState: a = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\nf()
// Warning 3944: (137-140): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\na = 0, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()
// Warning 6328: (150-163): CHC: Assertion violation happens here.\nCounterexample:\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()
// Warning 4984: (167-173): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 4984: (176-179): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 2661: (167-173): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 2661: (176-179): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -1,7 +1,7 @@
pragma experimental SMTChecker;
contract C {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c;
function mul(uint8 a, uint8 b) internal pure returns (uint8) {
uint8 c;
if (a != 0) {
c = a * b;
require(c / a == b);
@@ -10,3 +10,4 @@ contract C {
}
}
// ----
// Warning 6838: (161-171): BMC: Condition is always true.
@@ -1,13 +1,14 @@
pragma experimental SMTChecker;
contract C {
function mul(uint256 a, uint256 b) public pure returns (uint256) {
function mul(uint8 a, uint8 b) public pure returns (uint8) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
uint8 c = a * b;
require(c / a == b);
return c;
}
}
// ----
// Warning 4984: (160-165): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4984: (152-157): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\na = 128\nb = 2\n = 0\n\nTransaction trace:\nconstructor()\nmul(128, 2)
// Warning 6838: (169-179): BMC: Condition is always true.
@@ -2,10 +2,12 @@ pragma experimental SMTChecker;
contract C {
function f() public pure returns (uint16 x) {
x = 0xffff;
x += 32;
x = x << 8;
x = x >> 16;
unchecked {
x = 0xffff;
x += 32;
x = x << 8;
x = x >> 16;
}
assert(x == 0);
// Fails because x = 0.
assert(x == 10);
@@ -14,5 +16,4 @@ contract C {
// ====
// SMTIgnoreCex: yes
// ----
// Warning 4984: (109-116): CHC: Overflow (resulting value larger than 65535) happens here.
// Warning 6328: (193-208): CHC: Assertion violation happens here.
// Warning 6328: (215-230): CHC: Assertion violation happens here.
@@ -21,5 +21,6 @@ contract C {
*/
}
// ----
// Warning 4984: (87-90): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\nx = 255\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ndec_pre()\nState: x = 255\ninc_pre()
// Warning 4984: (87-90): CHC: Overflow (resulting value larger than 255) might happen here.
// Warning 3944: (127-130): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ndec_pre()
// Warning 2661: (87-90): BMC: Overflow (resulting value larger than 255) happens here.
@@ -14,4 +14,3 @@ contract C
}
// ----
// Warning 4984: (120-125): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 100\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (163-168): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 128\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -7,4 +7,4 @@ contract C {
}
}
// ----
// Warning 4984: (118-121): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 18, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\ny = 23158417847463239084714197001737581570653996933128112807891516801582625927988\n\n\nTransaction trace:\nconstructor()\nf([15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 18, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15], 23158417847463239084714197001737581570653996933128112807891516801582625927988)
// Warning 4984: (118-121): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\ny = 23158417847463239084714197001737581570653996933128112807891516801582625927988\n\n\nTransaction trace:\nconstructor()\nf([13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13], 23158417847463239084714197001737581570653996933128112807891516801582625927988)
@@ -4,7 +4,8 @@ contract C
{
function f(int8 x) public pure returns (int8) {
x = 100;
int8 y = x * 2;
int8 y;
unchecked { y = x * 2; }
assert(y == -56);
y = x * 100;
assert(y == 16);
@@ -12,5 +13,4 @@ contract C
}
}
// ----
// Warning 4984: (117-122): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 100\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (150-157): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 100\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (169-176): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 100\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -3,10 +3,11 @@ pragma experimental SMTChecker;
contract C
{
function f(uint8 x) public pure returns (uint8) {
uint8 y = x + 255;
uint8 y;
unchecked { y = x + 255; }
require(y >= x);
x = 255;
y = x + 1;
unchecked { y = x + 1; }
assert(y == 0);
y = x + 255;
assert(y == 254);
@@ -14,6 +15,4 @@ contract C
}
}
// ----
// Warning 4984: (109-116): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 1\n = 0\n\nTransaction trace:\nconstructor()\nf(1)
// Warning 4984: (154-159): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 255\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (185-192): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 255\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (218-225): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\n\nx = 255\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -2,19 +2,16 @@ pragma experimental SMTChecker;
contract C
{
function f(int8 x) public pure returns (int8) {
function f(int8 x) public pure {
x = 127;
int8 y = x + 1;
int8 y;
unchecked { y = x + 1; }
assert(y == -128);
y = x + 127;
unchecked { y = x + 127; }
assert(y == -2);
x = -127;
y = x + -127;
unchecked { y = x + -127; }
assert(y == 2);
}
}
// ----
// Warning 6321: (87-91): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 4984: (117-122): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 127\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (151-158): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 127\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 3944: (197-205): CHC: Underflow (resulting value less than -128) happens here.\nCounterexample:\n\nx = (- 127)\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -1,11 +0,0 @@
pragma experimental SMTChecker;
contract C
{
function add(uint x, uint y) public pure returns (uint) {
require(x + y >= x);
return x + y;
}
}
// ----
// Warning 4984: (115-120): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 1\ny = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nconstructor()\nadd(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935)
@@ -1,12 +0,0 @@
pragma experimental SMTChecker;
contract C
{
function add(uint x, uint y) public pure returns (uint) {
uint z = x + y;
require(z >= x);
return z;
}
}
// ----
// Warning 4984: (116-121): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 1\ny = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nconstructor()\nadd(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935)
@@ -9,4 +9,3 @@ contract C {
// ----
// Warning 3944: (111-116): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here.\nCounterexample:\n\nx = (- 1)\ny = (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)\n = 0\n\nTransaction trace:\nconstructor()\nf((- 1), (- 57896044618658097711785492504343953926634992332820282019728792003956564819968))
// Warning 4984: (111-116): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\nx = 1\ny = 57896044618658097711785492504343953926634992332820282019728792003956564819967\n = 0\n\nTransaction trace:\nconstructor()\nf(1, 57896044618658097711785492504343953926634992332820282019728792003956564819967)
// Warning 3944: (133-138): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here.\nCounterexample:\n\nx = (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)\ny = (- 1)\n = 0\n\nTransaction trace:\nconstructor()\nf((- 57896044618658097711785492504343953926634992332820282019728792003956564819968), (- 1))
@@ -4,13 +4,12 @@ contract C
{
function f(uint8 x) public pure returns (uint) {
x = 0;
uint8 y = x - 1;
uint8 y;
unchecked { y = x - 1; }
assert(y == 255);
y = x - 255;
unchecked { y = x - 255; }
assert(y == 1);
return y;
}
}
// ----
// Warning 3944: (117-122): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\n\nx = 0\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 3944: (150-157): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\n\nx = 0\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -4,18 +4,16 @@ contract C
{
function f(int8 x) public pure returns (int8) {
x = -2;
int8 y = x - 127;
int8 y;
unchecked { y = x - 127; }
assert(y == 127);
x = -128;
y = x - 127;
unchecked { y = x - 127; }
assert(y == 1);
x = 127;
y = x - (-127);
unchecked { y = x - (-127); }
assert(y == -2);
return y;
}
}
// ----
// Warning 3944: (116-123): CHC: Underflow (resulting value less than -128) happens here.\nCounterexample:\n\nx = (- 2)\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 3944: (163-170): CHC: Underflow (resulting value less than -128) happens here.\nCounterexample:\n\nx = (- 128)\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
// Warning 4984: (207-217): CHC: Overflow (resulting value larger than 127) happens here.\nCounterexample:\n\nx = 127\n = 0\n\nTransaction trace:\nconstructor()\nf(0)
@@ -2,9 +2,8 @@ pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
require(x + y >= x);
return x + y;
}
}
// ----
// Warning 4984: (114-119): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 1\ny = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nconstructor()\nf(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Warning 4984: (113-118): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\nx = 1\ny = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nconstructor()\nf(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935)
@@ -14,6 +14,6 @@ contract C {
// Warning 2072: (184-188): Unused local variable.
// Warning 8364: (155-156): Assertion checker does not yet implement type type(contract C)
// Warning 8364: (225-226): Assertion checker does not yet implement type type(contract C)
// Warning 6328: (252-268): CHC: Assertion violation happens here.\nCounterexample:\n\ndata = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n\n\nTransaction trace:\nconstructor()\nf([13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13])
// Warning 6328: (252-268): CHC: Assertion violation happens here.\nCounterexample:\n\ndata = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 18, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n\n\nTransaction trace:\nconstructor()\nf([15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 18, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15])
// Warning 8364: (155-156): Assertion checker does not yet implement type type(contract C)
// Warning 8364: (225-226): Assertion checker does not yet implement type type(contract C)
@@ -9,7 +9,8 @@ contract C
assert(tx.gasprice == msg.value);
assert(tx.origin == msg.sender);
uint x = block.number;
assert(x + 2 > block.number);
unchecked { x += 2; }
assert(x > block.number);
assert(block.timestamp > 10);
assert(gasleft() > 100);
}
@@ -20,7 +21,6 @@ contract C
// Warning 6328: (165-204): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (208-240): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (244-275): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 4984: (311-316): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (304-332): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (336-364): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (368-391): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (328-352): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (356-384): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (388-411): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
@@ -9,5 +9,5 @@ contract C
}
// ----
// Warning 2072: (96-102): Unused local variable.
// Warning 4984: (105-127): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 0\nb = 0\n\n\nTransaction trace:\nconstructor()\nf(0, 0)
// Warning 6328: (131-160): CHC: Assertion violation happens here.\nCounterexample:\n\na = 0\nb = 0\n\n\nTransaction trace:\nconstructor()\nf(0, 0)
// Warning 4984: (105-127): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 0\nb = 38\n\n\nTransaction trace:\nconstructor()\nf(0, 38)
// Warning 6328: (131-160): CHC: Assertion violation happens here.\nCounterexample:\n\na = 7719\nb = 38\n\n\nTransaction trace:\nconstructor()\nf(7719, 38)
@@ -19,4 +19,4 @@ contract C
// EVMVersion: >spuriousDragon
// ----
// Warning 2072: (224-240): Unused local variable.
// Warning 6328: (266-281): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\na = 0\ndata = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14, 5, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 27, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n\n\nTransaction trace:\nconstructor()\nState: x = 0\nf(0, [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14, 5, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 27, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
// Warning 6328: (266-281): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\na = 0\ndata = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 14, 7, 7, 7, 19, 7, 7, 7, 7, 7, 7, 7, 27, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n\n\nTransaction trace:\nconstructor()\nState: x = 0\nf(0, [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 14, 7, 7, 7, 19, 7, 7, 7, 7, 7, 7, 7, 27, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])
@@ -16,4 +16,4 @@ contract C
}
}
// ----
// Warning 6328: (266-286): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 3\n\n\nTransaction trace:\nconstructor()\nf(3)
// Warning 6328: (266-286): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\n\n\nTransaction trace:\nconstructor()\nf(0)
@@ -15,4 +15,4 @@ contract C {
}
}
// ----
// Warning 6328: (225-245): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 2, a: []}\ns2 = {x: 3, a: [6, 6, 6, 6, 6, 6, 6]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: 3, a: [6, 6, 6, 6, 6, 6, 6]})
// Warning 6328: (225-245): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 2, a: []}\ns2 = {x: 3, a: [5, 5, 5, 5, 5, 5]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: 3, a: [5, 5, 5, 5, 5, 5]})
@@ -15,5 +15,7 @@ contract C {
assert(s1.x == s2.x);
}
}
// ====
// SMTIgnoreCex: yes
// ----
// Warning 6328: (240-260): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 98, a: []}\ns2 = {x: (- 38), a: [6, 6, 6, 6, 6, 6, 6]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: (- 38), a: [6, 6, 6, 6, 6, 6, 6]})
// Warning 6328: (240-260): CHC: Assertion violation happens here.
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (uint y) {
unchecked{{
uint max = type(uint).max;
uint x = max + 1; // overflow not reported
y = x;
}}
assert(y == 0);
}
}
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract C {
uint public x = msg.value - 10; // can underflow
constructor() payable {}
}
contract D {
function h() internal returns (uint) {
return msg.value - 10; // can underflow
}
function f() public {
unchecked {
h(); // unchecked here does not mean h does not underflow
}
}
}
// ----
// Warning 3944: (66-80): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()
// Warning 3944: (193-207): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
@@ -0,0 +1,13 @@
pragma experimental SMTChecker;
contract C {
function add(uint16 a, uint16 b) public pure returns (uint16) {
return a + b; // can overflow
}
function f(uint16 a, uint16 b, uint16 c) public pure returns (uint16) {
unchecked { return add(a, b) + c; } // add can still overflow, `+ c` can't
}
}
// ----
// Warning 4984: (129-134): CHC: Overflow (resulting value larger than 65535) happens here.\nCounterexample:\n\na = 1\nb = 65535\n = 0\n\nTransaction trace:\nconstructor()\nadd(1, 65535)
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C {
modifier add(uint16 a, uint16 b) {
unchecked { a + b; } // overflow not reported
_;
}
function f(uint16 a, uint16 b, uint16 c) public pure add(a, b) returns (uint16) {
return b + c; // can overflow
}
}
// ----
// Warning 4984: (258-263): CHC: Overflow (resulting value larger than 65535) happens here.\nCounterexample:\n\na = 65535\nb = 1\nc = 65535\n = 0\n\nTransaction trace:\nconstructor()\nf(65535, 1, 65535)
@@ -0,0 +1,13 @@
pragma experimental SMTChecker;
contract test {
function f() public pure returns (bool) {
int256 x = -2**255;
unchecked { assert(-x == x); }
assert(-x == x); // CHC apparently does not create an underflow target for unary minus
return true;
}
}
// ----
// Warning 6328: (143-158): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = false\n\nTransaction trace:\nconstructor()\nf()
// Warning 2661: (150-152): BMC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
@@ -0,0 +1,27 @@
pragma experimental SMTChecker;
contract C {
function o() public pure {
uint x = type(uint).max;
unchecked { ++x; }
assert(x == type(uint).min);
}
function u() public pure {
uint x = type(uint).min;
unchecked { --x; }
assert(x == type(uint).max);
}
function o_int() public pure {
int x = type(int).max;
unchecked { ++x; }
assert(x == type(int).min);
}
function u_int() public pure {
int x = type(int).min;
unchecked { --x; }
assert(x == type(int).max);
}
}
@@ -0,0 +1,18 @@
pragma experimental SMTChecker;
contract C {
function f(int a, int b) public pure returns (int) {
return a % b; // can div by 0
}
function g(bool _check) public pure returns (int) {
int x = type(int).min;
if (_check) {
return x / -1; // can overflow
} else {
unchecked { return x / -1; } // overflow not reported
}
}
}
// ----
// Warning 4281: (118-123): CHC: Division by zero happens here.\nCounterexample:\n\na = 0\nb = 0\n = 0\n\nTransaction trace:\nconstructor()\nf(0, 0)
// Warning 4984: (275-281): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\n_check = true\n = 0\n\nTransaction trace:\nconstructor()\ng(true)
@@ -0,0 +1,15 @@
pragma experimental SMTChecker;
contract C {
function add(uint16 a, uint16 b) public pure returns (uint16) {
unchecked {
return a + b; // overflow not reported
}
}
function f(uint16 a) public pure returns (uint16) {
return add(a, 0x100) + 0x100; // should overflow on `+ 0x100`
}
}
// ----
// Warning 4984: (273-294): CHC: Overflow (resulting value larger than 65535) happens here.\nCounterexample:\n\na = 65024\n = 0\n\nTransaction trace:\nconstructor()\nf(65024)
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract C {
function div(uint256 a, uint256 b) public pure returns (uint256) {
// Does not disable div by zero check
unchecked {
return a / b;
}
}
function mod(uint256 a, uint256 b) public pure returns (uint256) {
// Does not disable div by zero check
unchecked {
return a % b;
}
}
}
// ----
// Warning 4281: (202-207): CHC: Division by zero happens here.\nCounterexample:\n\na = 0\nb = 0\n = 0\n\nTransaction trace:\nconstructor()\ndiv(0, 0)
// Warning 4281: (382-387): CHC: Division by zero happens here.\nCounterexample:\n\na = 0\nb = 0\n = 0\n\nTransaction trace:\nconstructor()\nmod(0, 0)