File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
regression/cbmc-shadow-memory/maybe-null1 Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ __CPROVER_field_decl_local ("field1" , (_Bool )1 );
7
+ int x ;
8
+ int * y = NULL ;
9
+ int c ;
10
+ int * z ;
11
+
12
+ // Goto-symex is expected to create a case split for dereferencing z.
13
+ __CPROVER_assume (c > 0 );
14
+ if (c )
15
+ z = & x ;
16
+ else
17
+ z = y ;
18
+
19
+ // Check initialization
20
+ assert (__CPROVER_get_field (z , "field1" ) == 1 );
21
+
22
+ // z actually points to x, which has valid shadow memory.
23
+ __CPROVER_set_field (z , "field1" , 0 );
24
+ assert (__CPROVER_get_field (z , "field1" ) == 0 );
25
+ assert (__CPROVER_get_field (& x , "field1" ) == 0 );
26
+
27
+ // y is NULL, which has no valid shadow memory
28
+ // and thus returns the default value.
29
+ assert (__CPROVER_get_field (y , "field1" ) == 1 );
30
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
You can’t perform that action at this time.
0 commit comments