File tree 4 files changed +36
-2
lines changed
regression/contracts-dfcc
invar_havoc_dynamic_array_const_idx
loop_assigns_inference-05
src/goto-instrument/contracts/dynamic-frames
4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ void main()
10
10
data [4 ] = 0 ;
11
11
12
12
for (unsigned i = 0 ; i < SIZE ; i ++ )
13
- __CPROVER_loop_invariant (i <= SIZE )
13
+ __CPROVER_assigns ( data [ 1 ], i ) __CPROVER_loop_invariant (i <= SIZE )
14
14
{
15
15
data [1 ] = i ;
16
16
}
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ #define SIZE 8
4
+
5
+ int main ()
6
+ {
7
+ int i = 0 ;
8
+ int * j = malloc (SIZE * sizeof (int ));
9
+ for (i = 0 ; i < SIZE ; i ++ )
10
+ // __CPROVER_assigns(h.pos, i)
11
+ __CPROVER_loop_invariant (0 <= i && i <= SIZE )
12
+ {
13
+ int * k ;
14
+ k = j + i ;
15
+ * k = 1 ;
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ CORE dfcc-only
2
+ main.c
3
+ --no-malloc-may-fail --dfcc main --apply-loop-contracts
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$
7
+ ^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$
8
+ ^\[main.loop_invariant_step.\d+\] line \d+ Check invariant after step for loop .*: SUCCESS$
9
+ ^\[main.loop_step_unwinding.\d+\] line \d+ Check step was unwound for loop .*: SUCCESS$
10
+ ^\[main.assigns.\d+\] line \d+ Check that \*k is assignable: SUCCESS
11
+ ^VERIFICATION SUCCESSFUL$
12
+ --
13
+ --
14
+ This test checks assigns __CPROVER_object_whole(k) is inferred correctly,
15
+ which requires widening *k to the whole object.
Original file line number Diff line number Diff line change @@ -262,7 +262,9 @@ static assignst dfcc_infer_loop_assigns_for_loop(
262
262
{
263
263
address_of_exprt address_of_expr (expr);
264
264
address_of_expr.add_source_location () = expr.source_location ();
265
- if (!is_constant (address_of_expr))
265
+ // Widen assigns targets to object_whole if `expr` is a dereference or
266
+ // with constant address.
267
+ if (expr.id () == ID_dereference || !is_constant (address_of_expr))
266
268
{
267
269
// Target address is not constant, widening to the whole object
268
270
result.emplace (make_object_whole_call_expr (address_of_expr, ns));
You can’t perform that action at this time.
0 commit comments