Skip to content

Add regression test for object accessed through integer pointer #5326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions regression/cbmc/integer-pointer/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>
#include <stdlib.h>

void main()
{
char *p = malloc(1);
__CPROVER_assume(__CPROVER_POINTER_OBJECT(p) == 2);
assert(0); // fails as expected

// same value as the malloc'd pointer above
char *q = (char *)((size_t)2 << sizeof(char *) * 8 - 8);

*p = 1;
*q = 2;

assert(*p == 1); // currently succeeds
}
13 changes: 13 additions & 0 deletions regression/cbmc/integer-pointer/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
KNOWNBUG
main.c
--pointer-check --no-simplify --no-propagation
^EXIT=10$
^SIGNAL=0$
\[main.assertion.1\] .*: FAILURE
\[main.assertion.2\] .*: FAILURE
--
^warning: ignoring
--
The assertion should fail as q has the same value as p. However since q was
initialized via an integer literal it points into __CPROVER_memory, and not to
the malloced memory. Issue #5327.