File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed
regression/cbmc-incr-smt2/pointers-relational-operators Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ #define NULL (void *)0
2+
3+ int main ()
4+ {
5+ int i = 12 ;
6+ int * x = & i ;
7+ int * y = x + 1 ;
8+ int * z = x - 1 ;
9+
10+ // Assertions on y's relation to x
11+ __CPROVER_assert (y != x , "y != x: expected successful" );
12+ __CPROVER_assert (y > x , "y > x: expected successful" );
13+ __CPROVER_assert (y < x , "y < x: expected failure" );
14+
15+ // Assertions on z's relation to x
16+ __CPROVER_assert (z != x , "z != x: expected successful" );
17+ __CPROVER_assert (z > x , "z > x: expected failure" );
18+ __CPROVER_assert (z < x , "z < x: expected success" );
19+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ pointers_stack_lessthan.c
3+ --trace
4+ \[main\.assertion\.1] line \d+ y != x: expected successful: SUCCESS
5+ \[main\.assertion\.2] line \d+ y > x: expected successful: SUCCESS
6+ \[main\.assertion\.3] line \d+ y < x: expected failure: FAILURE
7+ \[main\.assertion\.4] line \d+ z != x: expected successful: SUCCESS
8+ \[main\.assertion\.5] line \d+ z > x: expected failure: FAILURE
9+ \[main\.assertion\.6] line \d+ z < x: expected success: SUCCESS
10+ ^EXIT=10$
11+ ^SIGNAL=0$
12+ --
13+ --
14+ This is testing basic pointer relational operator support for three objects
15+ defined in the function's stack frame.
Original file line number Diff line number Diff line change 1+ #include <stdlib.h>
2+
3+ int main ()
4+ {
5+ int * a = malloc (sizeof (int ) * 5 );
6+
7+ for (int i = 0 ; i < 5 ; i ++ )
8+ * (a + i ) = i ;
9+
10+ for (int i = 0 ; i < 5 ; i ++ )
11+ {
12+ __CPROVER_assert (* (a + i ) >= i , "*(a + i) >= i: expected successful" );
13+ __CPROVER_assert (* (a + i ) <= i , "*(a + i) <= i: expected successful" );
14+ __CPROVER_assert (* (a + i ) == i , "*(a + i) <= i: expected successful" );
15+ __CPROVER_assert (* (a + i ) != i , "*(a + i) <= i: expected failure" );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ pointers_stack_malloc.c
3+ --trace
4+ \[main\.assertion\.1\] line \d+ \*\(a \+ i\) >= i: expected successful: SUCCESS
5+ \[main\.assertion\.2\] line \d+ \*\(a \+ i\) <= i: expected successful: SUCCESS
6+ \[main\.assertion\.3\] line \d+ \*\(a \+ i\) <= i: expected successful: SUCCESS
7+ \[main\.assertion\.4\] line \d+ \*\(a \+ i\) <= i: expected failure: FAILURE
8+ ^EXIT=10$
9+ ^SIGNAL=0$
10+ --
11+ --
12+ This is testing the support for relational operators as applied to pointer objects
13+ backed by a malloc and initialised to some values.
You can’t perform that action at this time.
0 commit comments