solidity/test/libsolidity/semanticTests/array/array_storage_length_access.sol
Daniel Kirchner 44da8507b1 Change default EVM version to Shanghai.
Co-authored-by: Rodrigo Q. Saramago <rodrigoqsaramago@gmail.com>
2023-05-08 16:34:23 +02:00

23 lines
684 B
Solidity

contract C {
uint[] storageArray;
function set_get_length(uint256 len) public returns (uint256) {
while(storageArray.length < len)
storageArray.push();
return storageArray.length;
}
}
// ----
// set_get_length(uint256): 0 -> 0
// set_get_length(uint256): 1 -> 1
// set_get_length(uint256): 10 -> 10
// set_get_length(uint256): 20 -> 20
// set_get_length(uint256): 0xFF -> 0xFF
// gas irOptimized: 96690
// gas legacy: 128571
// gas legacyOptimized: 110143
// set_get_length(uint256): 0xFFF -> 0xFFF
// gas irOptimized: 1220647
// gas legacy: 1689548
// gas legacyOptimized: 1393535
// set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas #