mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Implement support for memory allocation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
bytes memory x = new bytes(0);
|
||||
assert(x.length == 0);
|
||||
}
|
||||
function g() public pure {
|
||||
bytes memory x = new bytes(3);
|
||||
assert(x.length == 3);
|
||||
assert(x[0] == 0);
|
||||
assert(x[1] == 0);
|
||||
assert(x[2] == 0);
|
||||
}
|
||||
function h() public pure {
|
||||
bytes memory x = new bytes(3);
|
||||
assert(x.length == 3);
|
||||
x[0] = 0x12;
|
||||
x[1] = 0x34;
|
||||
assert(x[0] == 0x12);
|
||||
assert(x[1] == 0x34);
|
||||
// This should be an out-of-bounds assertion.
|
||||
x[5] = 0xff;
|
||||
assert(x[5] == 0xff);
|
||||
}
|
||||
function h(uint size) public pure {
|
||||
bytes memory x = new bytes(size);
|
||||
assert(x.length == size);
|
||||
require(size >= 2);
|
||||
x[0] = 0x12;
|
||||
x[1] = 0x34;
|
||||
assert(x[0] == 0x12);
|
||||
assert(x[1] == 0x34);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,36 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint[] memory x = new uint[](0);
|
||||
assert(x.length == 0);
|
||||
}
|
||||
function g() public pure {
|
||||
uint[] memory x = new uint[](3);
|
||||
assert(x.length == 3);
|
||||
assert(x[0] == 0);
|
||||
assert(x[1] == 0);
|
||||
assert(x[2] == 0);
|
||||
}
|
||||
function h() public pure {
|
||||
uint[] memory x = new uint[](3);
|
||||
assert(x.length == 3);
|
||||
x[0] = 0x12;
|
||||
x[1] = 0x34;
|
||||
assert(x[0] == 0x12);
|
||||
assert(x[1] == 0x34);
|
||||
// This should be an out-of-bounds assertion.
|
||||
x[5] = 0xff;
|
||||
assert(x[5] == 0xff);
|
||||
}
|
||||
function h(uint size) public pure {
|
||||
uint[] memory x = new uint[](size);
|
||||
assert(x.length == size);
|
||||
require(size >= 2);
|
||||
x[0] = 0x12;
|
||||
x[1] = 0x34;
|
||||
assert(x[0] == 0x12);
|
||||
assert(x[1] == 0x34);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -7,8 +7,8 @@ contract C {
|
||||
function(uint) returns (uint)[10] storage b = y;
|
||||
function(uint) external returns (uint)[] memory c;
|
||||
c = new function(uint) external returns (uint)[](200);
|
||||
assert(c.length == 200);
|
||||
a; b;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 4588: (361-410): Assertion checker does not yet implement this type of function call.
|
||||
|
||||
+1
-1
@@ -14,6 +14,7 @@ contract C {
|
||||
}
|
||||
function f() public pure {
|
||||
S[] memory s1 = new S[](3);
|
||||
assert(s1.length == 3);
|
||||
s1[0].x = 2;
|
||||
assert(s1[0].x == 2);
|
||||
s1[1].t.y = 3;
|
||||
@@ -27,4 +28,3 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 4588: (217-227): Assertion checker does not yet implement this type of function call.
|
||||
|
||||
+6
-6
@@ -14,6 +14,7 @@ contract C {
|
||||
}
|
||||
function f(S memory s2) public pure {
|
||||
S[] memory s1 = new S[](3);
|
||||
assert(s1.length == 3);
|
||||
s1[0].x = 2;
|
||||
assert(s1[0].x == s2.x);
|
||||
s1[1].t.y = 3;
|
||||
@@ -27,9 +28,8 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (257-280): Assertion violation happens here.
|
||||
// Warning 6328: (301-328): Assertion violation happens here.
|
||||
// Warning 6328: (350-379): Assertion violation happens here.
|
||||
// Warning 6328: (404-439): Assertion violation happens here.
|
||||
// Warning 6328: (467-508): Assertion violation happens here.
|
||||
// Warning 4588: (228-238): Assertion checker does not yet implement this type of function call.
|
||||
// Warning 6328: (283-306): Assertion violation happens here.
|
||||
// Warning 6328: (327-354): Assertion violation happens here.
|
||||
// Warning 6328: (376-405): Assertion violation happens here.
|
||||
// Warning 6328: (430-465): Assertion violation happens here.
|
||||
// Warning 6328: (493-534): Assertion violation happens here.
|
||||
|
||||
Reference in New Issue
Block a user