solidity/test/libsolidity/semanticTests/array/delete_on_array_of_structs.sol
Djordje Mijovic ad8d840ee7 [Sol->Yul] Implementing conversion of struct to struct pointer.
Co-authored-by: Daniel Kirchner <daniel@ekpyron.org>
2020-10-08 16:37:57 +02:00

23 lines
586 B
Solidity

// Test for a bug where we did not increment the counter properly while deleting a dynamic array.
contract C {
struct S {
uint256 x;
uint256[] y;
}
S[] data;
function f() public returns (bool) {
S storage s1 = data.push();
s1.x = 2**200;
S storage s2 = data.push();
s2.x = 2**200;
delete data;
return true;
}
}
// ====
// compileViaYul: also
// ----
// f() -> true # This code interprets x as an array length and thus will go out of gas. neither of the two should throw due to out-of-bounds access #