Skip to content

Commit 1cea202

Browse files
author
Enrico Steffinlongo
committed
Add __CPROVER_is_invalid_pointer regression test
1 parent 3f0adb8 commit 1cea202

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
// special value of the invalid pointer (object bits = 1 and offset = 0), as
7+
// checked for by __CPROVER_is_invalid_pointer()
8+
char *p = (size_t)1 << (sizeof(char *) * 8 - 8);
9+
__CPROVER_assert(
10+
__CPROVER_is_invalid_pointer(p), "INVALID pointer, so passing");
11+
int i;
12+
__CPROVER_assert(
13+
__CPROVER_is_invalid_pointer(&i), "VALID pointer, so failing");
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
pointer_is_invalid.c
3+
4+
Passing problem to incremental SMT2 solving
5+
\[main\.assertion\.1\] line \d+ INVALID pointer, so passing: SUCCESS
6+
\[main\.assertion\.2\] line \d+ VALID pointer, so failing: FAILURE
7+
^VERIFICATION FAILED$
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
Tests that an inconsistent assumption involving the special invalid pointer
13+
value and __CPROVER_r_ok() can be detected via assert(0).

regression/cbmc-incr-smt2/pointers/pointer_object3.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ int main()
1212
__CPROVER_POINTER_OBJECT(NULL) != 0,
1313
"expected to fail with object ID == 0");
1414
// In the case where the program contains a single address of operation,
15-
// the pointer object is going to be 1.
15+
// the pointer object is going to be 2 (1 is invalid pointer that is tested
16+
// somewhere else).
1617
__CPROVER_assert(
17-
__CPROVER_POINTER_OBJECT(&foo) != 1,
18-
"expected to fail with object ID == 1");
18+
__CPROVER_POINTER_OBJECT(&foo) != 2,
19+
"expected to fail with object ID == 2");
1920
}

regression/cbmc-incr-smt2/pointers/pointer_object3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CORE
22
pointer_object3.c
33

44
\[main\.assertion\.1] line \d+ expected to fail with object ID == 0: FAILURE
5-
\[main\.assertion\.2] line \d+ expected to fail with object ID == 1: FAILURE
5+
\[main\.assertion\.2] line \d+ expected to fail with object ID == 2: FAILURE
66
^VERIFICATION FAILED$
77
^EXIT=10$
88
^SIGNAL=0$

0 commit comments

Comments
 (0)