Assume that push will not overflow

This commit is contained in:
Leonardo Alt
2020-05-18 16:35:56 +02:00
parent 82db35e563
commit d4d26c02e4
8 changed files with 88 additions and 6 deletions
@@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
uint[] a;
function f(uint x) public {
require(a.length < 100000);
a.push(x);
assert(a[a.length - 1] == x);
}
}
@@ -0,0 +1,13 @@
pragma experimental SMTChecker;
contract C {
uint[][] a;
function f(uint[] memory x, uint y) public {
require(a.length < 100000);
a.push(x);
assert(a[a.length - 1][0] == x[0]);
require(a[0].length < 100000);
a[0].push(y);
assert(a[0][a[0].length - 1] == y);
}
}
@@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
uint256[] x;
constructor() public { x.push(42); }
function f() public {
x.push(23);
assert(x[0] == 42 || x[0] == 23);
}
}
@@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
uint256[] x;
constructor() public { x.push(42); }
function f() public {
x.push(23);
assert(x[0] == 42);
}
}
// ----
@@ -0,0 +1,12 @@
contract C {
uint256[] x;
function f(uint256 l) public {
require(x.length == 0);
x.push(42);
x.push(84);
for(uint256 i = 0; i < l; ++i)
x.push(23);
assert(x[0] == 42 || x[0] == 23);
}
}
@@ -0,0 +1,15 @@
pragma experimental SMTChecker;
contract C {
uint256[] x;
function f(uint256 l) public {
require(x.length == 0);
x.push(42);
x.push(84);
for(uint256 i = 0; i < l; ++i)
x.push(23);
assert(x[0] == 42);
}
}
// ----