Skip to content

Commit 7aa6f1b

Browse files
committed
Add a regression test based on the original code cited in #6168.
This also demonstrates the issue being fixed.
1 parent cdffe05 commit 7aa6f1b

File tree

2 files changed

+32
-0
lines changed
  • regression/goto-instrument/github_6168_infinite_unwinding_bug

2 files changed

+32
-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+
--enforce-all-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.

0 commit comments

Comments
 (0)