2020-11-23 18:06:44 +00:00
|
|
|
pragma abicoder v2;
|
2020-03-09 21:14:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
contract C {
|
|
|
|
bytes data;
|
|
|
|
struct S {
|
|
|
|
uint256 a;
|
|
|
|
uint256[] b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function f() public returns (S memory) {
|
|
|
|
S memory s;
|
|
|
|
s.a = 8;
|
|
|
|
s.b = new uint256[](3);
|
|
|
|
s.b[0] = 9;
|
|
|
|
s.b[1] = 10;
|
|
|
|
s.b[2] = 11;
|
|
|
|
data = abi.encode(s);
|
|
|
|
return abi.decode(data, (S));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-20 15:05:58 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-03-09 21:14:07 +00:00
|
|
|
// ----
|
|
|
|
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
|
2021-04-08 12:57:18 +00:00
|
|
|
// gas irOptimized: 193626
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 196426
|
2021-03-19 13:25:19 +00:00
|
|
|
// gas legacyOptimized: 193405
|