Skip to content

Commit 7a97c6e

Browse files
committed
Add regression test
Test to see if z3 has get-value problem
1 parent 1ecce42 commit 7a97c6e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdlib.h>
2+
void foo(char *dst, const char *src, size_t n)
3+
__CPROVER_requires(__CPROVER_is_fresh(src, n))
4+
__CPROVER_requires(__CPROVER_is_fresh(dst, n))
5+
__CPROVER_assigns(__CPROVER_object_from(dst))
6+
__CPROVER_ensures(__CPROVER_forall{size_t j; j < n ==> dst[j] == src[j]})
7+
{
8+
for(size_t i = 0; i < n; i++)
9+
__CPROVER_assigns(i, __CPROVER_object_from(dst))
10+
// commenting out the loop invariant to make the analysis fail and reveal the error
11+
// __CPROVER_loop_invariant(i <= n)
12+
// __CPROVER_loop_invariant(__CPROVER_forall{size_t j; j < i ==> dst[j] == src[j]})
13+
{
14+
dst[i] = src[i];
15+
}
16+
}
17+
18+
int main()
19+
{
20+
char *dst;
21+
char *src;
22+
size_t n;
23+
foo(dst, src, n);
24+
return 0;
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
main.c
3+
--dfcc main --enforce-contract foo --apply-loop-contracts --malloc-may-fail --malloc-fail-null _ --z3
4+
^\** 1 of 54 failed (2 iterations)$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
^VERIFICATION FAILED$
8+
--
9+
SMT2 solver returned error message:
10+
invalid get-value term, term must be ground and must not contain quantifiers
11+
--
12+
Checks that there are not get-value errors related to lambdas in array
13+
comprehension leading to quantifiers in z3 values.

0 commit comments

Comments
 (0)