solidity/test/libsolidity/smtCheckerTests/unchecked/unchecked_called_by_checked.sol

16 lines
556 B
Solidity
Raw Normal View History

2020-12-16 17:32:34 +00:00
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`
}
}
2021-03-31 15:11:54 +00:00
// ====
// SMTEngine: all
2020-12-16 17:32:34 +00:00
// ----
2021-03-31 15:11:54 +00:00
// Warning 4984: (240-261): CHC: Overflow (resulting value larger than 65535) happens here.\nCounterexample:\n\na = 65024\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(65024)\n C.add(65024, 256) -- internal call