File tree Expand file tree Collapse file tree 3 files changed +63
-3
lines changed
regression/cbmc/havoc_choice Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdbool.h>
3
+
4
+ bool nondet_bool ();
5
+
6
+ int main ()
7
+ {
8
+ char a = 'a' ;
9
+ char b = 'b' ;
10
+ char c = 'c' ;
11
+ char d = 'd' ;
12
+
13
+ char * p =
14
+ nondet_bool () ? (nondet_bool () ? & a : & b ) : (nondet_bool () ? & c : & d );
15
+
16
+ __CPROVER_havoc_object (p );
17
+
18
+ if (p == & a )
19
+ assert (a == 'a' );
20
+ else
21
+ assert (a == 'a' );
22
+
23
+ if (p == & b )
24
+ assert (b == 'b' );
25
+ else
26
+ assert (b == 'b' );
27
+
28
+ if (p == & c )
29
+ assert (c == 'c' );
30
+ else
31
+ assert (c == 'c' );
32
+
33
+ if (p == & d )
34
+ assert (d == 'd' );
35
+ else
36
+ assert (d == 'd' );
37
+ }
Original file line number Diff line number Diff line change
1
+ CORE new-smt-backend
2
+ main.c
3
+
4
+ \[main\.assertion\.1\] line \d+ assertion a \=\= \'a\'\: FAILURE
5
+ \[main\.assertion\.2\] line \d+ assertion a \=\= \'a\'\: SUCCESS
6
+ \[main\.assertion\.3\] line \d+ assertion b \=\= \'b\'\: FAILURE
7
+ \[main\.assertion\.4\] line \d+ assertion b \=\= \'b\'\: SUCCESS
8
+ \[main\.assertion\.5\] line \d+ assertion c \=\= \'c\'\: FAILURE
9
+ \[main\.assertion\.6\] line \d+ assertion c \=\= \'c\'\: SUCCESS
10
+ \[main\.assertion\.7\] line \d+ assertion d \=\= \'d\'\: FAILURE
11
+ \[main\.assertion\.8\] line \d+ assertion d \=\= \'d\'\: SUCCESS
12
+ ^EXIT=10$
13
+ ^SIGNAL=0$
14
+ ^VERIFICATION FAILED$
15
+ --
16
+ In the case where __CPROVER_havoc_object is applied to a pointer which points
17
+ to one of a selection of objects, only the one object which it pointed to should
18
+ be reassigned. This test is to cover the specific case where the value of the
19
+ pointer is expressed using nested ternary conditional expressions.
Original file line number Diff line number Diff line change @@ -46,11 +46,11 @@ void goto_symext::havoc_rec(
46
46
{
47
47
const if_exprt &if_expr=to_if_expr (dest);
48
48
49
- guardt guard_t =state. guard ;
49
+ guardt guard_t = guard;
50
50
guard_t .add (if_expr.cond ());
51
51
havoc_rec (state, guard_t , if_expr.true_case ());
52
52
53
- guardt guard_f=state. guard ;
53
+ guardt guard_f = guard;
54
54
guard_f.add (not_exprt (if_expr.cond ()));
55
55
havoc_rec (state, guard_f, if_expr.false_case ());
56
56
}
@@ -68,7 +68,11 @@ void goto_symext::havoc_rec(
68
68
}
69
69
else
70
70
{
71
- // consider printing a warning
71
+ INVARIANT_WITH_DIAGNOSTICS (
72
+ false ,
73
+ " Attempted to symex havoc applied to unsupported expression" ,
74
+ state.source .pc ->code ().pretty (),
75
+ dest.pretty ());
72
76
}
73
77
}
74
78
You can’t perform that action at this time.
0 commit comments