CBMC
|
Back to Code Contracts User Documentation
Refers to the value of a given object in the pre-state of a function within the ensures clause.
Important. This function may be used only within the context of __CPROVER_ensures
.
__CPROVER_old
takes a single argument, which is the identifier corresponding to a parameter of the function. For now, only scalars, pointers, and struct members are supported.
To illustrate the behavior of __CPROVER_old
, take a look at the example bellow. If the function returns a failure code, the value of *out
should not have been modified.
__CPROVER_loop_entry
takes a variable name that is in scope at the place of the loop contract.
__CPROVER_loop_entry
takes a snapshot of the variable value right before the first iteration of the loop. Caveat: to create a snapshot of an array, cast the array variable (which is a pointer per C's type system) to a pointer-to-array, and then dereference.
In this example the loop invariant asserts that x <= 200
is upheld before and after every iteration of the while
loop: