2020-03-20 23:32:30 +00:00
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
|
|
|
|
contract C {
|
|
|
|
function f(int8 a, uint8 b) public returns (int256) {
|
|
|
|
assembly {
|
|
|
|
a := 0xfffffff0
|
|
|
|
}
|
|
|
|
// Higher bits should be signextended before the shift
|
|
|
|
return a >> b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function g(int8 a, uint8 b) public returns (int256) {
|
|
|
|
assembly {
|
|
|
|
a := 0xf0
|
|
|
|
}
|
|
|
|
// Higher bits should be signextended before the shift
|
|
|
|
return a >> b;
|
|
|
|
}
|
|
|
|
}
|
2020-04-20 21:16:42 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-03-20 23:32:30 +00:00
|
|
|
// ----
|
|
|
|
// f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
|
|
|
// f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
// f(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
// f(int8,uint8): 0x00, 0x1003 -> FAILURE
|
|
|
|
// f(int8,uint8): 0x00, 0x1004 -> FAILURE
|
|
|
|
// g(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
|
|
|
// g(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
// g(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
// g(int8,uint8): 0x00, 0x1003 -> FAILURE
|
|
|
|
// g(int8,uint8): 0x00, 0x1004 -> FAILURE
|