solidity/test/libsolidity/semanticTests/array/create_memory_array.sol
2023-08-07 17:33:16 +02:00

24 lines
593 B
Solidity

contract C {
struct S {
uint256[2] a;
bytes b;
}
function f() public returns (bytes1, uint256, uint256, bytes1) {
bytes memory x = new bytes(200);
x[199] = "A";
uint256[2][] memory y = new uint256[2][](300);
y[203][1] = 8;
S[] memory z = new S[](180);
z[170].a[1] = 4;
z[170].b = new bytes(102);
z[170].b[99] = "B";
return (x[199], y[203][1], z[170].a[1], z[170].b[99]);
}
}
// ----
// f() -> "A", 8, 4, "B"
// gas irOptimized: 125819
// gas legacy: 121382
// gas legacyOptimized: 115488