2020-10-15 09:44:53 +00:00
|
|
|
contract C {
|
|
|
|
bytes data;
|
|
|
|
bytes otherData;
|
2020-12-14 17:34:40 +00:00
|
|
|
function fromMemory() public returns (bytes1) {
|
2020-10-15 09:44:53 +00:00
|
|
|
bytes memory t;
|
|
|
|
uint[2] memory x;
|
|
|
|
x[0] = type(uint).max;
|
|
|
|
data = t;
|
|
|
|
data.push();
|
|
|
|
return data[0];
|
|
|
|
}
|
2020-12-14 17:34:40 +00:00
|
|
|
function fromCalldata(bytes calldata x) public returns (bytes1) {
|
2020-10-15 09:44:53 +00:00
|
|
|
data = x;
|
|
|
|
data.push();
|
|
|
|
return data[0];
|
|
|
|
}
|
2020-12-14 17:34:40 +00:00
|
|
|
function fromStorage() public returns (bytes1) {
|
2020-10-15 09:44:53 +00:00
|
|
|
// zero-length but dirty higher order bits
|
|
|
|
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
|
|
|
|
data = otherData;
|
|
|
|
data.push();
|
|
|
|
return data[0];
|
|
|
|
}
|
|
|
|
}
|
2020-12-09 18:29:11 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-10-15 09:44:53 +00:00
|
|
|
// ----
|
|
|
|
// fromMemory() -> 0x00
|
|
|
|
// fromCalldata(bytes): 0x40, 0x60, 0x00, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
|
|
|
// fromStorage() -> 0x00
|