solidity/test/libsolidity/smtCheckerTests/out_of_bounds/array_2d_2.sol

17 lines
500 B
Solidity
Raw Normal View History

2021-03-23 18:15:14 +00:00
pragma experimental SMTChecker;
contract C {
uint[][] a;
function p() public { a.push(); }
function q(uint i) public {
require(i < a.length);
a[i].push();
}
function r(uint i, uint j) public view returns (uint) {
require(i < a.length);
return a[i][j]; // unsafe access
}
}
// ----
// Warning 6368: (257-264): CHC: Out of bounds access happens here.\nCounterexample:\na = [[]]\ni = 0\nj = 0\n = 0\n\nTransaction trace:\nC.constructor()\nState: a = []\nC.p()\nState: a = [[]]\nC.r(0, 0)