Skip to content

Commit d570aa5

Browse files
authored
Merge pull request #6340 from NlightNFotis/6168_workaround
Add workaround for issue described in #6168.
2 parents 7435884 + de9e891 commit d570aa5

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
static int adder(const int *a, const int *b)
5+
{
6+
return (*a + *b);
7+
}
8+
9+
int main()
10+
{
11+
int x = 1024;
12+
13+
int (*local_adder)(const int *, const int *) = adder;
14+
15+
while(x > 0)
16+
__CPROVER_loop_invariant(1 == 1)
17+
{
18+
x += local_adder(&x, &x); // loop detection fails
19+
//x += adder(&x, &x); // works fine
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--apply-loop-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
^\[main.1\] line \d+ Check loop invariant before entry: SUCCESS$
8+
^\[main.2\] line \d+ Check that loop invariant is preserved: SUCCESS$
9+
--
10+
--
11+
This is guarding against an issue described in https://github.com/diffblue/cbmc/issues/6168.

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
11541154
cmdline.isset(FLAG_ENFORCE_CONTRACT) ||
11551155
cmdline.isset(FLAG_ENFORCE_ALL_CONTRACTS))
11561156
{
1157+
do_indirect_call_and_rtti_removal();
11571158
code_contractst cont(goto_model, log);
11581159

11591160
if(cmdline.isset(FLAG_REPLACE_CALL))

0 commit comments

Comments
 (0)