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

39 lines
1.2 KiB
Solidity
Raw Normal View History

contract C {
function f(int a, int b) public pure returns (int x) {
x = a % b;
}
function g(int8 a, int8 b) public pure returns (int8 x) {
x = a % b;
}
}
// ====
2020-09-15 14:16:30 +00:00
// compileViaYul: also
2021-04-23 15:59:01 +00:00
// compileToEwasm: also
// ----
// f(int256,int256): 10, 3 -> 1
// f(int256,int256): 10, 2 -> 0
// f(int256,int256): 11, 2 -> 1
// f(int256,int256): -10, 3 -> -1
// f(int256,int256): 10, -3 -> 1
// f(int256,int256): -10, -3 -> -1
// f(int256,int256): 2, 2 -> 0
2020-10-13 11:28:39 +00:00
// f(int256,int256): 1, 0 -> FAILURE, hex"4e487b71", 0x12
// f(int256,int256): -1, 0 -> FAILURE, hex"4e487b71", 0x12
// f(int256,int256): 0, 0 -> FAILURE, hex"4e487b71", 0x12
// f(int256,int256): 0, 1 -> 0
// f(int256,int256): 0, -1 -> 0
// g(int8,int8): 10, 3 -> 1
// g(int8,int8): 10, 2 -> 0
// g(int8,int8): 11, 2 -> 1
// g(int8,int8): -10, 3 -> -1
// g(int8,int8): 10, -3 -> 1
// g(int8,int8): -10, -3 -> -1
// g(int8,int8): 2, 2 -> 0
2020-10-13 11:28:39 +00:00
// g(int8,int8): 1, 0 -> FAILURE, hex"4e487b71", 0x12
// g(int8,int8): -1, 0 -> FAILURE, hex"4e487b71", 0x12
// g(int8,int8): 0, 0 -> FAILURE, hex"4e487b71", 0x12
// g(int8,int8): 0, 1 -> 0
// g(int8,int8): 0, -1 -> 0
2020-12-14 13:29:54 +00:00
// g(int8,int8): -128, -128 -> 0
// g(int8,int8): -128, 127 -> -1