mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Zero initialize memory arrays
This commit is contained in:
@@ -20,6 +20,7 @@ object \"C_6\" {
|
||||
|
||||
function fun_f_5() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,6 +70,7 @@ object \"C_6\" {
|
||||
|
||||
function fun_f_5() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
||||
@@ -35,11 +35,18 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4_mpos {
|
||||
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
|
||||
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
|
||||
|
||||
vloc__4_mpos := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
|
||||
leave
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_string_memory_ptr() -> ret {
|
||||
ret := 96
|
||||
}
|
||||
|
||||
}
|
||||
object \"C_10_deployed\" {
|
||||
code {
|
||||
@@ -131,6 +138,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4_mpos {
|
||||
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
|
||||
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
|
||||
|
||||
vloc__4_mpos := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
|
||||
leave
|
||||
|
||||
@@ -147,6 +157,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_string_memory_ptr() -> ret {
|
||||
ret := 96
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,18 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32()
|
||||
vloc__4 := zero_value_for_type_t_bytes32_1
|
||||
|
||||
vloc__4 := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_bytes32()
|
||||
leave
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes32() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
object \"C_10_deployed\" {
|
||||
code {
|
||||
@@ -88,6 +95,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32()
|
||||
vloc__4 := zero_value_for_type_t_bytes32_1
|
||||
|
||||
vloc__4 := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_bytes32()
|
||||
leave
|
||||
|
||||
@@ -100,6 +110,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes32() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
|
||||
vloc__4 := zero_value_for_type_t_bytes4_1
|
||||
|
||||
let expr_6 := 0x61626364
|
||||
vloc__4 := convert_t_rational_1633837924_by_1_to_t_bytes4(expr_6)
|
||||
leave
|
||||
@@ -40,6 +43,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes4() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
object \"C_10_deployed\" {
|
||||
code {
|
||||
@@ -104,6 +111,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
|
||||
vloc__4 := zero_value_for_type_t_bytes4_1
|
||||
|
||||
let expr_6 := 0x61626364
|
||||
vloc__4 := convert_t_rational_1633837924_by_1_to_t_bytes4(expr_6)
|
||||
leave
|
||||
@@ -124,6 +134,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes4() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,18 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4_mpos {
|
||||
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
|
||||
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
|
||||
|
||||
vloc__4_mpos := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
|
||||
leave
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_string_memory_ptr() -> ret {
|
||||
ret := 96
|
||||
}
|
||||
|
||||
}
|
||||
object \"C_10_deployed\" {
|
||||
code {
|
||||
@@ -139,6 +146,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4_mpos {
|
||||
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
|
||||
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
|
||||
|
||||
vloc__4_mpos := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
|
||||
leave
|
||||
|
||||
@@ -155,6 +165,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_string_memory_ptr() -> ret {
|
||||
ret := 96
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
|
||||
vloc__4 := zero_value_for_type_t_bytes4_1
|
||||
|
||||
let expr_6 := 0xaabbccdd
|
||||
vloc__4 := convert_t_rational_2864434397_by_1_to_t_bytes4(expr_6)
|
||||
leave
|
||||
@@ -40,6 +43,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes4() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
object \"C_10_deployed\" {
|
||||
code {
|
||||
@@ -104,6 +111,9 @@ object \"C_10\" {
|
||||
}
|
||||
|
||||
function fun_f_9() -> vloc__4 {
|
||||
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
|
||||
vloc__4 := zero_value_for_type_t_bytes4_1
|
||||
|
||||
let expr_6 := 0xaabbccdd
|
||||
vloc__4 := convert_t_rational_2864434397_by_1_to_t_bytes4(expr_6)
|
||||
leave
|
||||
@@ -124,6 +134,10 @@ object \"C_10\" {
|
||||
|
||||
}
|
||||
|
||||
function zero_value_for_split_t_bytes4() -> ret {
|
||||
ret := 0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
contract C {
|
||||
function f(uint n, uint m) public {
|
||||
function() internal returns (uint)[] memory arr = new function() internal returns (uint)[](n);
|
||||
arr[m]();
|
||||
}
|
||||
function f2(uint n, uint m, uint a, uint b) public {
|
||||
function() internal returns (uint)[][] memory arr = new function() internal returns (uint)[][](n);
|
||||
for (uint i = 0; i < n; ++i)
|
||||
arr[i] = new function() internal returns (uint)[](m);
|
||||
arr[a][b]();
|
||||
}
|
||||
function g(uint n, uint m) public {
|
||||
function() external returns (uint)[] memory arr = new function() external returns (uint)[](n);
|
||||
arr[m]();
|
||||
}
|
||||
function g2(uint n, uint m, uint a, uint b) public {
|
||||
function() external returns (uint)[][] memory arr = new function() external returns (uint)[][](n);
|
||||
for (uint i = 0; i < n; ++i)
|
||||
arr[i] = new function() external returns (uint)[](m);
|
||||
arr[a][b]();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 1823621, 12323 -> FAILURE
|
||||
// f2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE
|
||||
// g(uint256,uint256): 1823621, 12323 -> FAILURE
|
||||
// g2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
uint test1;
|
||||
uint test2;
|
||||
uint test3;
|
||||
uint test4;
|
||||
uint test5;
|
||||
uint test6;
|
||||
uint test7;
|
||||
mapping (string => uint) map;
|
||||
function set(string memory s, uint n, uint m, uint a, uint b) public returns (uint) {
|
||||
map[s] = 0;
|
||||
uint[][] memory x = new uint[][](n);
|
||||
for (uint i = 0; i < n; ++i)
|
||||
x[i] = new uint[](m);
|
||||
return x[a][b];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 0, 0, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 1, 3, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 3, 3, 32, "01234567890123456789012345678901" -> FAILURE
|
||||
// set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 1, 5, 32, "01234567890123456789012345678901" -> FAILURE
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
uint test1;
|
||||
uint test2;
|
||||
uint test3;
|
||||
uint test4;
|
||||
uint test5;
|
||||
uint test6;
|
||||
uint test7;
|
||||
mapping (string => uint) map;
|
||||
function set(string memory s, uint n, uint m) public returns (uint) {
|
||||
map[s] = 0;
|
||||
uint[4][] memory x = new uint[4][](n);
|
||||
return x[m][0];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(string,uint256,uint256): 0x60, 2, 0, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256): 0x60, 2, 1, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256): 0x60, 2, 2, 32, "01234567890123456789012345678901" -> FAILURE
|
||||
// set(string,uint256,uint256): 0x60, 200, 199, 32, "01234567890123456789012345678901" -> 0
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
uint test1;
|
||||
uint test2;
|
||||
uint test3;
|
||||
uint test4;
|
||||
uint test5;
|
||||
uint test6;
|
||||
uint test7;
|
||||
mapping (string => uint) map;
|
||||
function set(string memory s) public returns (uint[3] memory x, uint[2] memory y, uint[] memory z, uint t) {
|
||||
map[s] = 0;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(string): 0x20, 32, "01234567890123456789012345678901" -> 0, 0, 0, 0, 0, 0xe0, 0, 0
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
uint test1;
|
||||
uint test2;
|
||||
uint test3;
|
||||
uint test4;
|
||||
uint test5;
|
||||
uint test6;
|
||||
uint test7;
|
||||
mapping (string => uint) map;
|
||||
function set(string memory s) public returns (uint) {
|
||||
map[s] = 0;
|
||||
uint[3] memory x;
|
||||
return x[2];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(string): 0x20, 32, "01234567890123456789012345678901" -> 0
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
uint test1;
|
||||
uint test2;
|
||||
uint test3;
|
||||
uint test4;
|
||||
uint test5;
|
||||
uint test6;
|
||||
uint test7;
|
||||
mapping (string => uint) map;
|
||||
function set(string memory s, uint n, uint a) public returns (uint) {
|
||||
map[s] = 0;
|
||||
uint[] memory x = new uint[](n);
|
||||
return x[a];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(string,uint256,uint256): 0x60, 5, 0, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256): 0x60, 5, 1, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256): 0x60, 5, 4, 32, "01234567890123456789012345678901" -> 0
|
||||
// set(string,uint256,uint256): 0x60, 5, 5, 32, "01234567890123456789012345678901" -> FAILURE
|
||||
@@ -0,0 +1,25 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
function() internal returns (uint) _f;
|
||||
_f();
|
||||
}
|
||||
function g() public {
|
||||
function() external returns (uint) _g;
|
||||
_g();
|
||||
}
|
||||
function h1() internal returns (function() internal returns (uint) _h) {}
|
||||
function h2() public {
|
||||
h1()();
|
||||
}
|
||||
function k1() internal returns (function() external returns (uint) _k) {}
|
||||
function k2() public {
|
||||
k1()();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> FAILURE
|
||||
// g() -> FAILURE
|
||||
// h2() -> FAILURE
|
||||
// k2() -> FAILURE
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
uint[] arr1;
|
||||
uint[][] arr2;
|
||||
function f() internal returns (uint[] storage ptr1, uint[][] storage ptr2) {
|
||||
ptr1 = arr1;
|
||||
ptr2 = arr2;
|
||||
}
|
||||
function g() public returns (uint, uint) {
|
||||
return (arr1.length, arr2.length);
|
||||
}
|
||||
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g() -> 0, 0
|
||||
Reference in New Issue
Block a user