solidity/test/libsolidity/smtCheckerTests/loops/while_loop_array_assignment_memory_storage.sol
2019-09-13 12:40:53 +02:00

26 lines
555 B
Solidity

pragma experimental SMTChecker;
contract LoopFor2 {
uint[] a;
function testUnboundedForLoop(uint n, uint[] memory b, uint[] memory c) public {
b[0] = 900;
a = b;
require(n > 0 && n < 100);
uint i;
while (i < n) {
b[i] = i + 1;
c[i] = b[i];
++i;
}
// Fails due to aliasing, since both b and c are
// memory references of same type.
assert(b[0] == c[0]);
assert(a[0] == 900);
assert(b[0] == 900);
}
}
// ----
// Warning: (362-382): Assertion violation happens here
// Warning: (409-428): Assertion violation happens here