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:
@@ -0,0 +1 @@
|
||||
--model-checker-engine bmc --model-checker-bmc-loop-iterations 3
|
||||
@@ -0,0 +1,11 @@
|
||||
Warning: BMC: Assertion violation happens here.
|
||||
--> model_checker_bmc_loop_iterations/input.sol:10:3:
|
||||
|
|
||||
10 | assert(x == 3);
|
||||
| ^^^^^^^^^^^^^^
|
||||
Note: Counterexample:
|
||||
x = 2
|
||||
|
||||
Note: Callstack:
|
||||
Note: False negatives are possible when unrolling loops.
|
||||
This is due to the possibility that the BMC loop iteration setting is smaller than the actual number of iterations needed to complete a loop.
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
do {
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(x == 3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
--model-checker-engine bmc --model-checker-bmc-loop-iterations bmc
|
||||
@@ -0,0 +1 @@
|
||||
the argument ('bmc') for option '--model-checker-bmc-loop-iterations' is invalid
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
--model-checker-engine bmc --model-checker-bmc-loop-iterations
|
||||
@@ -0,0 +1 @@
|
||||
the argument ('model_checker_bmc_loop_iterations_no_argument/input.sol') for option '--model-checker-bmc-loop-iterations' is invalid
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources":
|
||||
{
|
||||
"Source":
|
||||
{
|
||||
"content": "// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
do {
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(x == 2);
|
||||
}
|
||||
}"
|
||||
}
|
||||
},
|
||||
"settings":
|
||||
{
|
||||
"modelChecker":
|
||||
{
|
||||
"engine": "bmc",
|
||||
"bmcLoopIterations": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"errors":
|
||||
[
|
||||
{
|
||||
"component": "general",
|
||||
"errorCode": "6002",
|
||||
"formattedMessage": "Info: BMC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them.
|
||||
|
||||
",
|
||||
"message": "BMC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them.",
|
||||
"severity": "info",
|
||||
"type": "Info"
|
||||
}
|
||||
],
|
||||
"sources":
|
||||
{
|
||||
"Source":
|
||||
{
|
||||
"id": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources":
|
||||
{
|
||||
"Source":
|
||||
{
|
||||
"content": "// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
require(x == 0);
|
||||
do {
|
||||
++x;
|
||||
} while (x < 2);
|
||||
assert(x == 2);
|
||||
}
|
||||
}"
|
||||
}
|
||||
},
|
||||
"settings":
|
||||
{
|
||||
"modelChecker":
|
||||
{
|
||||
"engine": "bmc",
|
||||
"bmcLoopIterations": "bmc"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"errors":
|
||||
[
|
||||
{
|
||||
"component": "general",
|
||||
"formattedMessage": "settings.modelChecker.bmcLoopIterations must be an unsigned integer.",
|
||||
"message": "settings.modelChecker.bmcLoopIterations must be an unsigned integer.",
|
||||
"severity": "error",
|
||||
"type": "JSONError"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user