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