File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
regression/contracts/github_6168_infinite_unwinding_bug Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff 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))
You can’t perform that action at this time.
0 commit comments