solidity/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol

23 lines
684 B
Solidity
Raw Normal View History

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
2021-09-15 15:01:40 +00:00
// gas irOptimized: 96690
// gas legacy: 126722
// gas legacyOptimized: 107818
// set_get_length(uint256): 0xFFF -> 0xFFF
2022-05-23 10:54:18 +00:00
// gas irOptimized: 1217848
// gas legacy: 1702119
// gas legacyOptimized: 1398420
// set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas #