Description
CBMC version: 5.34.0
Operating system: Linux
Test case:
#include <assert.h>
#include <stdlib.h>
int main() {
char *a;
// lots of errors with `--pointer-check` enabled
assert(*a == *a);
// no errors even with `--pointer-check` enabled
assert(
__CPROVER_forall {
int i ; (0 <= i && i < 1) ==> *(a+i) == *(a+i)
}
);
}
Exact command line resulting in the issue:
$ cbmc --pointer-check test.c
What behaviour did you expect:
NULL
and invalid pointer issues would be checked within both assertions.
What happened instead:
NULL
and invalid pointer issues are checked within first assertion but not the second. Commenting out the first assertion results in VERIFICATION SUCCESSFUL
output even with --pointer-check
flag.
The bounds for the quantified variable are constants and CBMC does not ignore the quantifier (with the SAT backend).
Even with the SMT backend, with which quantifiers are not unrolled, --pointer-check
is not really checked within the quantified expression. Running the following gives VERIFICATION SUCCESSFUL
on commenting the first assertion:
$ cbmc --z3 --pointer-check test.c