Skip to content

Commit c4a28fe

Browse files
committed
Add test for __CPROVER_same_object() with pointer pointing within memory block
1 parent 1b733b9 commit c4a28fe

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

regression/cbmc/same-object-04/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
char *p = malloc(10);
7+
char *q = p + 5;
8+
9+
assert(__CPROVER_same_object(p, q));
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
main.c
3+
--no-simplify --no-propagation
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Check that __CPROVER_same_object() is true when given a pointer to the start of
11+
a memory block, and a pointer to within the memory block. We use --no-simplify
12+
and --no-propagation to ensure that the case is not solved by the constant
13+
propagation and thus tests the constraint encoding.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Check that __CPROVER_same_object() is true when given a pointer to the start of
11+
a memory block, and a pointer to within the memory block.

0 commit comments

Comments
 (0)