Description
CBMC version: 5.34.0
Operating system: N/A
The CBMC Manual section on “Memory Primitives / Detecting potential misuses of memory primitives” (http://cprover.diffblue.com/memory-primitives.html#autotoc_md108) ends with the following text:
"While the first three primitives [__CPROVER_POINTER_OBJECT, __CPROVER_POINTER_OFFSET, and __CPROVER_same_object] have well-defined semantics even on invalid pointers, using them on invalid pointers is usually unintended in user programs. Thus, they have been included in the --pointer-primitive-check option."
We are encountering various cases where it is our intention to use these primitives on invalid pointers — specifically as assumptions about uninitialized pointers so as to constrain them. For example, we may malloc one pointer p and then seek to constrain a second pointer q to point into the same region as p.
To facilitate this without abandoning the pointer primitive checks entirely we need the addition of a new flag that causes CBMC to check for valid pointer use only on those primitives where behavior on invalid pointers is undefined. One possible name might be --lax-pointer-primitive-check. There are probably better ones.
It should be possible to use both this new flag (--lax-pointer-primitive-check) and the existing flag (--pointer-primitive-check) such that a #pragma can be used to disable just the stricter checks on a region of code.