solidity/test/libsolidity/semanticTests/viaYul/detect_add_overflow.sol

20 lines
575 B
Solidity
Raw Normal View History

2019-03-18 10:21:41 +00:00
contract C {
function f(uint a, uint b) public pure returns (uint x) {
x = a + b;
}
function g(uint8 a, uint8 b) public pure returns (uint8 x) {
x = a + b;
}
}
// ====
2020-09-15 14:16:30 +00:00
// compileViaYul: also
2021-04-23 15:59:01 +00:00
// compileToEwasm: also
2019-03-18 10:21:41 +00:00
// ----
// f(uint256,uint256): 5, 6 -> 11
// f(uint256,uint256): -2, 1 -> -1
2020-10-13 11:28:39 +00:00
// f(uint256,uint256): -2, 2 -> FAILURE, hex"4e487b71", 0x11
// f(uint256,uint256): 2, -2 -> FAILURE, hex"4e487b71", 0x11
2019-03-18 10:21:41 +00:00
// g(uint8,uint8): 128, 64 -> 192
// g(uint8,uint8): 128, 127 -> 255
2020-10-13 11:28:39 +00:00
// g(uint8,uint8): 128, 128 -> FAILURE, hex"4e487b71", 0x11