solidity/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol
2021-07-05 13:46:53 +02:00

30 lines
545 B
Solidity

pragma abicoder v2;
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));
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
// gas irOptimized: 203556
// gas legacy: 206126
// gas legacyOptimized: 203105