File tree 2 files changed +35
-0
lines changed
regression/cbmc-incr-smt2/pointers-conversions 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ int cmp (const void * p1 , const void * p2 )
2
+ {
3
+ int x = * (int * )p1 ;
4
+ int y = * (int * )p2 ;
5
+
6
+ return (x < y ) ? -1 : ((x == y ) ? 0 : 1 );
7
+ }
8
+
9
+ int main ()
10
+ {
11
+ int a = 5 ;
12
+ int b = 6 ;
13
+ int c = 7 ;
14
+
15
+ __CPROVER_assert (cmp (& a , & b ) == -1 , "expected result == -1: success" );
16
+ __CPROVER_assert (cmp (& c , & b ) == 1 , "expected result == 1: success" );
17
+ __CPROVER_assert (cmp (& c , & c ) == 0 , "expected result == 0: success" );
18
+ __CPROVER_assert (cmp (& c , & c ) == 1 , "expected result == 1: failure" );
19
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ pointer_to_int.c
3
+ --trace
4
+ \[main\.assertion\.1\] line \d+ expected result == -1: success: SUCCESS
5
+ \[main\.assertion\.2\] line \d+ expected result == 1: success: SUCCESS
6
+ \[main\.assertion\.3\] line \d+ expected result == 0: success: SUCCESS
7
+ \[main\.assertion\.4\] line \d+ expected result == 1: failure: FAILURE
8
+ ^VERIFICATION FAILED$
9
+ ^EXIT=10$
10
+ ^SIGNAL=0$
11
+ --
12
+ --
13
+ This test is covering basic conversion of casting of different pointer values,
14
+ which are then dereferenced and used in the function. We are asserting against
15
+ the result of the function, which cannot be right, unless the conversions
16
+ work as they should.
You can’t perform that action at this time.
0 commit comments