-
Notifications
You must be signed in to change notification settings - Fork 274
Add a __CPROVER_postcondition builtin #4921
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int func(int a) | ||
{ | ||
__CPROVER_precondition(a > 10, "Argument should be larger than 10"); | ||
int rval = a - 10; | ||
__CPROVER_postcondition(rval > 1, "Return value should be positive"); | ||
return rval; | ||
} | ||
|
||
int main() | ||
{ | ||
int a = 11; | ||
int rval = func(a); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
main.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
void func(int a) | ||
{ | ||
__CPROVER_precondition(a > 10, "Argument should be larger than 10."); | ||
} | ||
|
||
int main() | ||
{ | ||
int a = 10; | ||
|
||
func(a); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
main.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ void __CPROVER_assume(__CPROVER_bool assumption); | |
void __VERIFIER_assume(__CPROVER_bool assumption); | ||
void __CPROVER_assert(__CPROVER_bool assertion, const char *description); | ||
void __CPROVER_precondition(__CPROVER_bool precondition, const char *description); | ||
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Random place for a comment: I think this strictly requires documentation. When should users make use of this? I note that the commit message doesn't have a body either, so it's really hard to see when that should be used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Where is a good place to add documentation for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed elsewhere: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would structure this differently. The new feature, which is contract checking, is a different use-case, and externalises this to users of CBMC. My experience is that users like manuals that are structured by use-case. Thus, I would suggest to add a new chapter, say titled "Modular Verification using Code Contracts", or the like, to discuss this use-case separately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While this is a good intention, I don't think it will remain as constrained if people find it useful in other places as well. Anything that can be used will be used at some point... |
||
void __CPROVER_havoc_object(void *); | ||
__CPROVER_bool __CPROVER_equal(); | ||
__CPROVER_bool __CPROVER_same_object(const void *, const void *); | ||
|
Uh oh!
There was an error while loading. Please reload this page.