Skip to content

Commit 194df6c

Browse files
authored
Merge pull request #5326 from danpoe/tests/integer-pointer
Add regression test for object accessed through integer pointer
2 parents 6d832ec + 36c2838 commit 194df6c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
char *p = malloc(1);
7+
__CPROVER_assume(__CPROVER_POINTER_OBJECT(p) == 2);
8+
assert(0); // fails as expected
9+
10+
// same value as the malloc'd pointer above
11+
char *q = (char *)((size_t)2 << sizeof(char *) * 8 - 8);
12+
13+
*p = 1;
14+
*q = 2;
15+
16+
assert(*p == 1); // currently succeeds
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
KNOWNBUG
2+
main.c
3+
--pointer-check --no-simplify --no-propagation
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] .*: FAILURE
7+
\[main.assertion.2\] .*: FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
The assertion should fail as q has the same value as p. However since q was
12+
initialized via an integer literal it points into __CPROVER_memory, and not to
13+
the malloced memory. Issue #5327.

0 commit comments

Comments
 (0)