Skip to content

Commit a11a005

Browse files
committed
Add a simple test for the conversion of pointer arithmetic/subtraction.
This works without any changes to our conversion of `minus_exprt`s because there's a transformation between the frontend and the backend that converts a (*a - 3) to (*a + (-3)).
1 parent 17c8286 commit a11a005

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#define NULL (void *)0
2+
3+
int main()
4+
{
5+
int *x;
6+
int *y = x - 2;
7+
__CPROVER_assume(x != NULL);
8+
__CPROVER_assume(y != NULL);
9+
10+
__CPROVER_assert(y == x, "expected failure after pointer manipulation");
11+
__CPROVER_assert(y != x, "expected successful after pointer manipulation");
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
subtraction_simple.c
3+
--trace
4+
\[main\.assertion\.1\] line \d+ expected failure after pointer manipulation: FAILURE
5+
\[main\.assertion\.2\] line \d+ expected successful after pointer manipulation: SUCCESS
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
This test is similar to the one in `addition_simple.desc`, but testing end-to-end
11+
the conversion of a subtraction case of pointer arithmetic.

0 commit comments

Comments
 (0)