mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add optional bounds to unroll loops in BMC model checker
This commit is contained in:
@@ -122,6 +122,9 @@ SMTCheckerTest::SMTCheckerTest(string const& _filename): SyntaxTest(_filename, E
|
||||
m_shouldRun = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
auto const& bmcLoopIterations = m_reader.sizetSetting("BMCLoopIterations", 1);
|
||||
m_modelCheckerSettings.bmcLoopIterations = std::optional<unsigned>{bmcLoopIterations};
|
||||
}
|
||||
|
||||
TestCase::TestResult SMTCheckerTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
|
||||
|
||||
@@ -55,6 +55,8 @@ protected:
|
||||
Set in m_modelCheckerSettings.
|
||||
SMTSolvers: `all`, `cvc4`, `z3`, `none`, where the default is `all`.
|
||||
Set in m_modelCheckerSettings.
|
||||
BMCLoopIterations: number of loop iterations for BMC engine, the default is 1.
|
||||
Set in m_modelCheckerSettings.
|
||||
*/
|
||||
|
||||
ModelCheckerSettings m_modelCheckerSettings;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
contract C
|
||||
{
|
||||
function f(bool x) public pure { require(x); for (;x;) {} }
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// ----
|
||||
// Warning 6838: (65-66): BMC: Condition is always true.
|
||||
@@ -1,8 +0,0 @@
|
||||
contract C
|
||||
{
|
||||
function f(bool x) public pure { require(x); while (x) {} }
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// ----
|
||||
// Warning 6838: (66-67): BMC: Condition is always true.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
do {
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
{
|
||||
++x;
|
||||
++x;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
if (x >= 2)
|
||||
++x;
|
||||
++x;
|
||||
} while (x < 3);
|
||||
assert(x == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
} while (true);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
uint x;
|
||||
|
||||
function condition() private returns(bool) {
|
||||
++x;
|
||||
return x < 3;
|
||||
}
|
||||
|
||||
function f() public {
|
||||
require(x == 0);
|
||||
do {
|
||||
} while (condition());
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Warning 2661: (77-80): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
do {
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 4661: (102-116): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
break;
|
||||
} while (x < 3);
|
||||
assert(x == 0);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 2
|
||||
// ----
|
||||
// Warning 5740: (87-92): Unreachable code.
|
||||
// Warning 4661: (97-111): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
continue;
|
||||
} while (x < 2);
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 2
|
||||
// ----
|
||||
// Warning 4661: (100-114): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
break;
|
||||
} while (x < 3);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Warning 5740: (87-92): Unreachable code.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
do {
|
||||
if (x > 0)
|
||||
break;
|
||||
++x;
|
||||
} while (x < 3);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
do {
|
||||
if (x >= 0) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
++x;
|
||||
} while (x < 3);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
do {
|
||||
if (x > 0) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
++x;
|
||||
} while (x < 3);
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
do {
|
||||
++x;
|
||||
if (x > 1) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
if (x > 0) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
++x;
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
if (x > 0) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
break;
|
||||
} while (++x < 2);
|
||||
// loop condition is not executed after break
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 5740: (79-86): Unreachable code.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
if (x > 1) {
|
||||
break;
|
||||
}
|
||||
if (x >= 0) {
|
||||
x = 10;
|
||||
continue;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(x == 10);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
do {
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
if (x >= 0) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
} while (x < 4);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
do {
|
||||
++x;
|
||||
if (x == 3) {
|
||||
continue;
|
||||
}
|
||||
++x;
|
||||
} while (x < 3);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,25 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
uint y = 0;
|
||||
do {
|
||||
++x;
|
||||
if (x == 2) {
|
||||
++x;
|
||||
y = 1;
|
||||
continue;
|
||||
}
|
||||
if (x == 3) {
|
||||
y = 2;
|
||||
continue;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(y == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
uint y = 0;
|
||||
do {
|
||||
++x;
|
||||
if (x > 0) {
|
||||
y = 1;
|
||||
continue;
|
||||
}
|
||||
if (x > 0) {
|
||||
y = 2;
|
||||
continue;
|
||||
}
|
||||
} while (x < 3);
|
||||
assert(y == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,25 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
uint i;
|
||||
do {
|
||||
++i;
|
||||
if (i == 2) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
if (i == 1) {
|
||||
x = 1;
|
||||
continue;
|
||||
}
|
||||
} while (i < 3);
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint z) public pure {
|
||||
uint x = 0;
|
||||
require(z == 0);
|
||||
do {
|
||||
uint y = 0;
|
||||
do {
|
||||
++z;
|
||||
++y;
|
||||
} while (y < 2);
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(z == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint z) public pure {
|
||||
uint x = 0;
|
||||
require(z == 0);
|
||||
do {
|
||||
uint y = 0;
|
||||
do {
|
||||
if (y > 0)
|
||||
break;
|
||||
++z;
|
||||
++y;
|
||||
} while (y < 2);
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(z == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint z) public pure {
|
||||
uint x = 0;
|
||||
require(z == 0);
|
||||
do {
|
||||
uint y = 0;
|
||||
do {
|
||||
++y;
|
||||
if (y > 0)
|
||||
continue;
|
||||
++z;
|
||||
} while (y < 2);
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(z == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
do {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
++x;
|
||||
} while (x < 3 || y == 1);
|
||||
// BMC loop iteration setting is not enough to leave the loop
|
||||
assert(x == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
assert(y == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
do {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
++x;
|
||||
} while (x < 3 || y == 1);
|
||||
// BMC loop iteration setting is just enough to leave the loop
|
||||
assert(x == 3); // should hold
|
||||
assert(y == 1); // should hold
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
do {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
++x;
|
||||
} while (x < 3 || y == 1);
|
||||
// BMC loop iteration setting is more than enough to leave the loop
|
||||
assert(x == 3); // should hold
|
||||
assert(y == 1); // should hold
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
uint y;
|
||||
do {
|
||||
++y;
|
||||
if (y == 2)
|
||||
x = 3;
|
||||
} while (y < 3);
|
||||
// nothing is reported because loop condition is true after unrolling the loop one time
|
||||
assert(x == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -1,19 +0,0 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x < 100);
|
||||
for(uint i = 0; i < 10; ++i) {
|
||||
// Overflows due to resetting x.
|
||||
x = x + 1;
|
||||
}
|
||||
assert(x < 14);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Warning 4984: (143-148): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||
// Warning 6328: (156-170): CHC: Assertion violation happens here.
|
||||
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
// Warning 2661: (143-148): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
@@ -14,4 +14,4 @@ contract C
|
||||
// ----
|
||||
// Warning 4984: (106-111): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
// Warning 2661: (106-111): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i)
|
||||
++x;
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
x = i;
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
if (i > 1)
|
||||
x = 10;
|
||||
assert(x == 10);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 0; ++i)
|
||||
++x;
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (; x < 0; ++x) {}
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
for (uint i = 1; i < 3;) {
|
||||
x = i;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C
|
||||
{
|
||||
uint x;
|
||||
|
||||
function condition() private returns(bool) {
|
||||
++x;
|
||||
return x < 3;
|
||||
}
|
||||
|
||||
function f() public {
|
||||
require(x == 0);
|
||||
for (; condition();) {
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Warning 2661: (71-74): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,31 @@
|
||||
contract C
|
||||
{
|
||||
uint x;
|
||||
uint y;
|
||||
|
||||
function condition() private returns(bool) {
|
||||
++x;
|
||||
return x < 3;
|
||||
}
|
||||
|
||||
function expression() private {
|
||||
++y;
|
||||
}
|
||||
|
||||
function f() public {
|
||||
require(x == 0);
|
||||
require(y == 0);
|
||||
for (; condition(); expression()) {
|
||||
}
|
||||
assert(x == 3);
|
||||
assert(y == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Warning 2661: (80-83): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Warning 2661: (140-143): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i)
|
||||
++x;
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 4661: (92-106): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 0);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 5740: (77-80): Unreachable code.
|
||||
// Warning 4661: (108-122): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
++x;
|
||||
continue;
|
||||
}
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 4661: (111-125): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
break;
|
||||
++x;
|
||||
}
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Warning 5740: (77-80): Unreachable code.
|
||||
// Warning 5740: (97-100): Unreachable code.
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Warning 5740: (77-80): Unreachable code.
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 0)
|
||||
break;
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
++x;
|
||||
if (i > 0)
|
||||
break;
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 1) {
|
||||
x = 1;
|
||||
break;
|
||||
}
|
||||
if (i > 1) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 1) {
|
||||
x = 1;
|
||||
break;
|
||||
}
|
||||
if (i >= 1) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (;;) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (;;) {
|
||||
break;
|
||||
++x;
|
||||
}
|
||||
assert(x == 0);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Warning 5740: (78-81): Unreachable code.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (;x < 2;) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 1) {
|
||||
break;
|
||||
}
|
||||
if (i >= 0) {
|
||||
x = 10;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 10);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
if (i > 0) {
|
||||
x = 1;
|
||||
break;
|
||||
}
|
||||
if (i >= 0) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 2
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 0) {
|
||||
x = 1;
|
||||
break;
|
||||
} else {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (i > 1)
|
||||
continue;
|
||||
++x;
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
if (i == 1) {
|
||||
x = 1;
|
||||
continue;
|
||||
}
|
||||
if (i == 0) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (x > 1) {
|
||||
x = 10;
|
||||
continue;
|
||||
}
|
||||
if (x > 0) {
|
||||
x = 11;
|
||||
continue;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
assert(x == 10);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (; x < 2; ++x) {
|
||||
if (x > 1) {
|
||||
x = 10;
|
||||
continue;
|
||||
}
|
||||
if (x > 0) {
|
||||
x = 11;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// x > 0 branch triggers x = 11 and continue triggers ++x loop expression
|
||||
assert(x == 12);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (; x < 2; ++x) {
|
||||
continue;
|
||||
}
|
||||
// loop expression is executed after continue
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
for (;;) {
|
||||
x = 1;
|
||||
}
|
||||
assert(x == 1000);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
for (uint j = 0; j < 2; ++j)
|
||||
++x;
|
||||
}
|
||||
assert(x == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
for (uint j = 0; j < 2; ++j) {
|
||||
x = x + 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 5740: (92-95): Unreachable code.
|
||||
// Warning 5740: (126-129): Unreachable code.
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
for (uint j = 0; j < 2; ++j) {
|
||||
if (i > 0)
|
||||
continue;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
for (; x < 3 || y == 1; ++x) {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
}
|
||||
// BMC loop iteration setting is not enough to leave the loop
|
||||
assert(x == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
assert(y == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
for (; x < 3 || y == 1; ++x) {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
}
|
||||
// BMC loop iteration setting is just enough to leave the loop
|
||||
assert(x == 3); // should hold - no assumptions on value if didn't complete loop
|
||||
assert(y == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
int y = 0;
|
||||
for (; x < 3 || y == 1; ++x) {
|
||||
if (x >= 3)
|
||||
y = 1;
|
||||
}
|
||||
// BMC loop iteration setting is more than enough to leave the loop
|
||||
assert(x == 3); // should hold - no assumptions on value if didn't complete loop
|
||||
assert(y == 0); // should hold - no assumptions on value if didn't complete loop
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
for (uint i = 0; i < 2; ++i) {
|
||||
++x;
|
||||
}
|
||||
// nothing is reported because loop condition is still true after BMCLoopIterations
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -10,4 +10,3 @@ contract C {
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
// Warning 6838: (90-96): BMC: Condition is always true.
|
||||
|
||||
@@ -13,4 +13,3 @@ contract C {
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
// Warning 6838: (106-112): BMC: Condition is always true.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
require(x == 2);
|
||||
for (; x > 2;) {}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
// Warning 6838: (90-95): BMC: Condition is always false.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
uint y;
|
||||
while (y < 3) {
|
||||
++y;
|
||||
if (y == 2)
|
||||
x = 3;
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 2
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
{
|
||||
++x;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
if (x >= 2)
|
||||
++x;
|
||||
++x;
|
||||
}
|
||||
assert(x == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
x = 0;
|
||||
while (x < 1) {
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (true) {
|
||||
++x;
|
||||
}
|
||||
assert(x == 1000);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 1
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
uint x;
|
||||
|
||||
function condition() private returns(bool) {
|
||||
++x;
|
||||
return x < 3;
|
||||
}
|
||||
|
||||
function f() public {
|
||||
require(x == 0);
|
||||
while (condition()) {
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 5
|
||||
// ----
|
||||
// Warning 2661: (77-80): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
while (x < 2) {
|
||||
++x;
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 4661: (98-112): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 2) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 0);
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 2
|
||||
// ----
|
||||
// Warning 4661: (93-107): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 2) {
|
||||
++x;
|
||||
continue;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Warning 4661: (96-110): BMC: Assertion violation happens here.
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
if (x > 0)
|
||||
break;
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
if (x > 0) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
if (x > 0) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
if (x > 1) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
if (x > 0) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
if (x > 0) {
|
||||
x = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
while (x < 3) {
|
||||
if (x >= 0) {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x = 0;
|
||||
while (x < 3) {
|
||||
++x;
|
||||
break;
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Warning 5740: (94-97): Unreachable code.
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
if (x > 1) {
|
||||
break;
|
||||
}
|
||||
if (x >= 0) {
|
||||
x = 10;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 10);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
while (x < 3) {
|
||||
if (x > 1) {
|
||||
x = 3;
|
||||
break;
|
||||
}
|
||||
if (x >= 0) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
uint i;
|
||||
while (i < 3) {
|
||||
++i;
|
||||
if (i > 1)
|
||||
continue;
|
||||
++x;
|
||||
}
|
||||
assert(x == 1);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
uint i;
|
||||
while (i < 3) {
|
||||
++i;
|
||||
if (i == 2) {
|
||||
x = 2;
|
||||
continue;
|
||||
}
|
||||
if (i == 1) {
|
||||
x = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function f(uint z) public pure {
|
||||
uint x = 0;
|
||||
require(z == 0);
|
||||
while (x < 2) {
|
||||
uint y = 0;
|
||||
while (y < 2) {
|
||||
++z;
|
||||
++y;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
assert(z == 4);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f(uint z) public pure {
|
||||
uint x = 0;
|
||||
require(z == 0);
|
||||
while (x < 2) {
|
||||
uint y = 0;
|
||||
while (y < 2) {
|
||||
if (y > 0)
|
||||
break;
|
||||
++z;
|
||||
++y;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
assert(z == 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 3
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint x;
|
||||
uint i;
|
||||
while (i < 3) {
|
||||
++i;
|
||||
uint j;
|
||||
while (j < 3) {
|
||||
++j;
|
||||
if (i > 1)
|
||||
continue;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// SMTSolvers: z3
|
||||
// BMCLoopIterations: 4
|
||||
// ----
|
||||
// Info 6002: BMC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user