Skip to content

Commit 90e509b

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

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 {
7+
size_t j;
8+
j<n ==> dst[j] == src[j]
9+
})
10+
{
11+
for(size_t i = 0; i < n; i++)
12+
__CPROVER_assigns(i, __CPROVER_object_from(dst))
13+
// commenting out the loop invariant to make the analysis fail and reveal the error
14+
// __CPROVER_loop_invariant(i <= n)
15+
// __CPROVER_loop_invariant(__CPROVER_forall{size_t j; j < i ==> dst[j] == src[j]})
16+
{
17+
dst[i] = src[i];
18+
}
19+
}
20+
21+
int main()
22+
{
23+
char *dst;
24+
char *src;
25+
size_t n;
26+
foo(dst, src, n);
27+
return 0;
28+
}
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)