Skip to content

Commit 0aaf191

Browse files
Remi Delmastautschnig
Remi Delmas
authored andcommitted
Adding a test that demonstrates the non-duplication.
1 parent e2e895e commit 0aaf191

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdlib.h>
2+
const int N = 100;
3+
int main()
4+
{
5+
int *buf = malloc(N * sizeof(*buf));
6+
char *lb = (((char *)buf) - __CPROVER_POINTER_OFFSET(buf));
7+
char *ub = (((char *)buf) - __CPROVER_POINTER_OFFSET(buf)) +
8+
__CPROVER_OBJECT_SIZE(buf) - 1;
9+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CORE
2+
main.c
3+
--pointer-overflow-check _ --pointer-overflow-check --unsigned-overflow-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[malloc.assertion.1\].*: SUCCESS
7+
^\[malloc.assertion.2\].*: SUCCESS
8+
^\[main.overflow.1\].*: SUCCESS
9+
^\[main.pointer_arithmetic.1\].*: SUCCESS
10+
^\[main.pointer_arithmetic.2\].*: SUCCESS
11+
^\[main.pointer_arithmetic.3\].*: SUCCESS
12+
^\[main.pointer_arithmetic.4\].*: SUCCESS
13+
^\[main.pointer_arithmetic.5\].*: SUCCESS
14+
^\[main.pointer_arithmetic.6\].*: SUCCESS
15+
^\[main.pointer_arithmetic.7\].*: SUCCESS
16+
^\[main.pointer_arithmetic.8\].*: SUCCESS
17+
^\[main.pointer_arithmetic.9\].*: SUCCESS
18+
^\[main.pointer_arithmetic.10\].*: SUCCESS
19+
^\[main.pointer_arithmetic.11\].*: SUCCESS
20+
^\[main.pointer_arithmetic.12\].*: SUCCESS
21+
^\[main.pointer_arithmetic.13\].*: SUCCESS
22+
^\[main.pointer_arithmetic.14\].*: SUCCESS
23+
^\[main.pointer_arithmetic.15\].*: SUCCESS
24+
^\[main.pointer_arithmetic.16\].*: SUCCESS
25+
^\[main.pointer_arithmetic.17\].*: SUCCESS
26+
^\*\* 0 of 20 failed \(1 iterations\)
27+
^VERIFICATION SUCCESSFUL$
28+
--
29+
^\[main.overflow.\d+\].*: FAILURE
30+
--
31+
Checks that assertions generated by the first --pointer-overflow-check:
32+
- do not get duplicated by the second --unsigned-overflow-check
33+
- do not get instrumented with --unsigned-overflow-check (would fail the proof)
34+
35+
We expect 20 assertions to be generated:
36+
In the goto-instrument run:
37+
- 2 for using malloc
38+
- 17 caused by --pointer-overflow-check
39+
40+
In the final cbmc run:
41+
- 0 caused by --pointer-overflow-check
42+
- 1 caused by the --unsigned-overflow-check

0 commit comments

Comments
 (0)