solidity/test/libsolidity/smtCheckerTests/unchecked/check_var_init.sol
2020-12-30 12:14:30 +01:00

21 lines
673 B
Solidity

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()