Skip to content

Commit b8b6272

Browse files
committed
enable nondeterministic pointers
This commit enables the use of nondeterministic pointers, to allow declarative modeling of states that include pointers.
1 parent c3d7235 commit b8b6272

File tree

11 files changed

+139
-1
lines changed

11 files changed

+139
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
int *nondet_pointer();
2+
3+
int main()
4+
{
5+
int x = 123;
6+
int *p = &x;
7+
int *q = nondet_pointer();
8+
9+
if(p == q)
10+
__CPROVER_assert(*q == 123, "value of *q");
11+
12+
return 0;
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nondet-pointer1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int *nondet_pointer();
2+
3+
int main()
4+
{
5+
int x = 123, y = 456;
6+
int *px = &x;
7+
int *py = &y;
8+
int *q = nondet_pointer();
9+
10+
if(q == px || q == py)
11+
__CPROVER_assert(*q == 123 || *q == 456, "value of *q");
12+
13+
return 0;
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nondet-pointer1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int *nondet_pointer();
2+
3+
int main()
4+
{
5+
int some_array[10];
6+
int *p = some_array;
7+
int *q = nondet_pointer();
8+
int index;
9+
10+
__CPROVER_assume(index >= 0 && index < 10);
11+
__CPROVER_assume(q == p);
12+
13+
q[index] = 123;
14+
15+
__CPROVER_assert(some_array[index] == 123, "value of array[index]");
16+
17+
return 0;
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nondet-pointer1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int *nondet_pointer();
2+
3+
int main()
4+
{
5+
int some_array[10];
6+
int *p = some_array;
7+
int *q = nondet_pointer();
8+
int index;
9+
10+
__CPROVER_assume(index >= 0 && index < 10);
11+
__CPROVER_assume(q == p + index);
12+
13+
*q = 123;
14+
15+
__CPROVER_assert(some_array[index] == 123, "value of array[index]");
16+
17+
return 0;
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nondet-pointer1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
int *nondet_pointer();
2+
3+
int main()
4+
{
5+
int some_array[10];
6+
int *p = some_array;
7+
int *q = nondet_pointer();
8+
int index;
9+
10+
__CPROVER_assume(index >= 0 && index < 10);
11+
__CPROVER_assume(__CPROVER_same_object(p, q));
12+
__CPROVER_assume(__CPROVER_POINTER_OFFSET(q) == sizeof(int) * index);
13+
14+
*q = 123;
15+
16+
__CPROVER_assert(some_array[index] == 123, "value of array[index]");
17+
18+
return 0;
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nondet-pointer1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)