File tree Expand file tree Collapse file tree 18 files changed +205
-0
lines changed
regression/goto-instrument
expand-pointer-predicates1
expand-pointer-predicates2
expand-pointer-predicates3
expand-pointer-predicates4
expand-pointer-predicates5
expand-pointer-predicates6
expand-pointer-predicates7
expand-pointer-predicates8
expand-pointer-predicates9 Expand file tree Collapse file tree 18 files changed +205
-0
lines changed Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int * x ;
4
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (x ));
5
+ * x = 1 ;
6
+ return 0 ;
7
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int * x ;
4
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (x , sizeof (int )));
5
+ * x = 1 ;
6
+ return 0 ;
7
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int * x ;
4
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (x , sizeof (int )));
5
+ __CPROVER_assert (
6
+ __CPROVER_points_to_valid_memory (x , sizeof (int )), "Assert matches assume" );
7
+ return 0 ;
8
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int x ;
4
+ int * y = & x ;
5
+ __CPROVER_assert (__CPROVER_points_to_valid_memory (y ), "Assert works on &" );
6
+ return 0 ;
7
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
Original file line number Diff line number Diff line change
1
+ struct bar
2
+ {
3
+ int w ;
4
+ int x ;
5
+ int y ;
6
+ int z ;
7
+ };
8
+
9
+ int main ()
10
+ {
11
+ struct bar s ;
12
+ s .z = 5 ;
13
+ int * x_pointer = & (s .x );
14
+ __CPROVER_assert (
15
+ __CPROVER_points_to_valid_memory (x_pointer , 3 * sizeof (int )),
16
+ "Variable length assert" );
17
+ assert (x_pointer [2 ] == 5 );
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^\[main.assertion.1\] Variable length assert: SUCCESS$
5
+ ^\[main.assertion.2\] assertion x_pointer\[\(signed long( long)? int\)2\] == 5: SUCCESS$
6
+ ^EXIT=0$
7
+ ^SIGNAL=0$
8
+ ^VERIFICATION SUCCESSFUL$
9
+ --
10
+ --
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ struct my_struct
4
+ {
5
+ int * field1 ;
6
+ int * field2 ;
7
+ };
8
+
9
+ void example (struct my_struct * s )
10
+ {
11
+ s -> field2 = malloc (sizeof (* (s -> field2 )));
12
+ }
13
+
14
+ int main ()
15
+ {
16
+ struct my_struct * s ;
17
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (s ));
18
+ example (s );
19
+ __CPROVER_assert (__CPROVER_points_to_valid_memory (s -> field2 ), "" );
20
+ return 0 ;
21
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^\[main.assertion.1\] : SUCCESS$
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ ^VERIFICATION SUCCESSFUL$
8
+ --
9
+ --
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ struct my_struct
4
+ {
5
+ int * field ;
6
+ };
7
+
8
+ void example (struct my_struct * s )
9
+ {
10
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (s ));
11
+ size_t size ;
12
+ __CPROVER_assume (size == sizeof (* (s -> field )));
13
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (s -> field , size ));
14
+ int read = * (s -> field );
15
+ }
16
+
17
+ int main ()
18
+ {
19
+ struct my_struct * s ;
20
+ example (s );
21
+ return 0 ;
22
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ int main ()
4
+ {
5
+ int * x ;
6
+ int * y ;
7
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (x , 2 * sizeof (int )));
8
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (y , 2 * sizeof (int ) - 1 ));
9
+ (void )(x [0 ]); // Should succeed
10
+ (void )(x [1 ]); // Should succeed
11
+ (void )(x [2 ]); // Should fail
12
+ (void )(x [-1 ]); // Should fail
13
+ (void )(y [0 ]); // Should succeed
14
+ (void )(y [1 ]); // Should fail
15
+ return 0 ;
16
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: dead object in x\[\(signed long( long)? int\)0\]: SUCCESS$
5
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in x\[\(signed long( long)? int\)0\]: SUCCESS$
6
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in x\[\(signed long( long)? int\)1\]: SUCCESS$
7
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in x\[\(signed long( long)? int\)2\]: FAILURE$
8
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in x\[\(signed long( long)? int\)-1\]: FAILURE$
9
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: dead object in y\[\(signed long( long)? int\)0\]: SUCCESS$
10
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in y\[\(signed long( long)? int\)0\]: SUCCESS$
11
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in y\[\(signed long( long)? int\)1\]: FAILURE$
12
+ ^EXIT=10$
13
+ ^SIGNAL=0$
14
+ ^VERIFICATION FAILED$
15
+ --
16
+ --
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ int main ()
4
+ {
5
+ char * x ;
6
+ __CPROVER_assume (__CPROVER_points_to_valid_memory (x ));
7
+ (void )(* x ); // Should succeed
8
+ (void )(* (x + 1 )); // Should fail
9
+ (void )(* (x - 1 )); // Should fail
10
+ return 0 ;
11
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --expand-pointer-predicates
4
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: dead object in \*x: SUCCESS$
5
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in \*x: SUCCESS$
6
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in x\[\(signed long( long)? int\)1\]: FAILURE$
7
+ ^\[main.pointer_dereference.[0-9]+\] dereference failure: pointer outside object bounds in \*\(x - \(signed long( long)? int\)1\): FAILURE$
8
+ ^EXIT=10$
9
+ ^SIGNAL=0$
10
+ ^VERIFICATION FAILED$
11
+ --
12
+ --
You can’t perform that action at this time.
0 commit comments