-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CONTRACTS: separation checks using nondet demonic variable
- Replace bool array indexed by object ID with nondet demonic variable to implement separation checks. - Fix test: don't use is fresh under negation format
- Loading branch information
Remi Delmas
committed
Jan 25, 2025
1 parent
3d79560
commit d490670
Showing
10 changed files
with
210 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
|
||
int z; | ||
|
||
// clang-format off | ||
int foo(int *x, int *y) | ||
__CPROVER_assigns(z, *x) | ||
__CPROVER_requires( | ||
__CPROVER_is_fresh(x, sizeof(int)) && | ||
*x > 0 && | ||
*x < 4) | ||
__CPROVER_ensures( | ||
__CPROVER_is_fresh(y, sizeof(int)) && | ||
!__CPROVER_is_fresh(x, sizeof(int)) && | ||
x != NULL && | ||
x != y && | ||
__CPROVER_return_value == *x + 5) | ||
int *foo() | ||
// clang-format off | ||
__CPROVER_ensures(__CPROVER_is_fresh(__CPROVER_return_value, sizeof(int))) | ||
// clang-format on | ||
{ | ||
*x = *x + 4; | ||
y = malloc(sizeof(*y)); | ||
*y = *x; | ||
z = *y; | ||
return (*x + 5); | ||
int *ret = malloc(sizeof(int)); | ||
__CPROVER_assume(ret); | ||
return ret; | ||
} | ||
|
||
int main() | ||
{ | ||
int n = 4; | ||
n = foo(&n, &n); | ||
assert(!(n < 4)); | ||
foo(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.