solidity/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol
2021-03-29 11:02:31 +02:00

29 lines
717 B
Solidity

// Test to see if cleanup is performed properly during array copying
contract C {
uint128[] x;
function f() public returns(bool) {
x.push(42); x.push(42); x.push(42); x.push(42);
uint128[] memory y = new uint128[](1);
y[0] = 23;
x = y;
assembly { sstore(x.slot, 4) }
assert(x[0] == 23);
assert(x[1] == 0);
assert(x[2] == 0);
// Issue 9832: the cleanup was only performed for the first packed type leaving the rest of
// the slot dirty.
assert(x[3] == 0);
return true;
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
// gas irOptimized: 107807
// gas legacy: 107335
// gas legacyOptimized: 105857