solidity/test/libsolidity/semanticTests/array/create_memory_array_too_large.sol
Harikrishnan Mulackal e4e200f29f Changelog and tests
2020-05-11 15:29:05 +05:30

27 lines
788 B
Solidity

contract C {
function f() public returns (uint256) {
uint256 l = 2**256 / 32;
// This used to work without causing an error.
uint256[] memory x = new uint256[](l);
uint256[] memory y = new uint256[](1);
x[1] = 42;
// This used to overwrite the value written above.
y[0] = 23;
return x[1];
}
function g() public returns (uint256) {
uint256 l = 2**256 / 2 + 1;
// This used to work without causing an error.
uint16[] memory x = new uint16[](l);
uint16[] memory y = new uint16[](1);
x[2] = 42;
// This used to overwrite the value written above.
y[0] = 23;
return x[2];
}}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE
// g() -> FAILURE