Skip to content
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

CONTRACTS: separation checks using nondet demonic variable #8576

Merged
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
34 changes: 7 additions & 27 deletions regression/contracts-dfcc/test_aliasing_ensure/main.c
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;
}
4 changes: 0 additions & 4 deletions regression/contracts-dfcc/test_aliasing_ensure/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ main.c
^EXIT=0$
^SIGNAL=0$
\[foo.postcondition.\d+\].*Check ensures clause of contract contract::foo for function foo: SUCCESS$
\[foo.assigns.\d+\].*Check that \*x is assignable: SUCCESS
\[foo.assigns.\d+\].*Check that \*y is assignable: SUCCESS
\[foo.assigns.\d+\].*Check that z is assignable: SUCCESS
\[main.assertion.\d+\].*assertion \!\(n \< 4\): SUCCESS
^VERIFICATION SUCCESSFUL$
--
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ int foo(int *x)
ptr_ok(x))
__CPROVER_ensures(
!ptr_ok(x) &&
!__CPROVER_is_fresh(x, sizeof(int)) &&
return_ok(__CPROVER_return_value, x))
// clang-format on
{
Expand Down
Loading
Loading