File tree 3 files changed +33
-0
lines changed
regression/contracts/github_6168_infinite_unwinding_bug 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()
1154
1154
cmdline.isset (FLAG_ENFORCE_CONTRACT) ||
1155
1155
cmdline.isset (FLAG_ENFORCE_ALL_CONTRACTS))
1156
1156
{
1157
+ do_indirect_call_and_rtti_removal ();
1157
1158
code_contractst cont (goto_model, log );
1158
1159
1159
1160
if (cmdline.isset (FLAG_REPLACE_CALL))
You can’t perform that action at this time.
0 commit comments