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

Strange behaviour of programs with contract #22

Open
jesper-amilon opened this issue Sep 5, 2024 · 2 comments
Open

Strange behaviour of programs with contract #22

jesper-amilon opened this issue Sep 5, 2024 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@jesper-amilon
Copy link
Collaborator

This contract verifies as safe, but it seems it should not, since the assertion in main() does not follow from the post-condition for foo(). If you change the contract to "ensures x >= 0", it seems to verify.
int x;
/*@
ensures x > 0;
*/
void foo(){
x =2;
}

void main() {
foo();
assert(x == 2);
}

@zafer-esen zafer-esen added the bug Something isn't working label Sep 11, 2024
@zafer-esen
Copy link
Collaborator

TriCera shows that the post-condition holds when verifying foo, but uses the method body in main rather than the weaker postcondition, which allows the verification of the assertion. Essentially, the ensures clause is currently equivalent to an assert statement at the end of its method body.

The expected behaviour would be to use the provided contracts rather than the method body at call sites. This would also be a step in the direction of modular verification in TriCera.

@jesper-amilon
Copy link
Collaborator Author

Ideally maybe the user could specify with a comman-line flag if tricera should verify modularly or not when seeing a contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants