-
Notifications
You must be signed in to change notification settings - Fork 273
Expanding __CPROVER_{r,w,rw}_ok must not introduce overflow [depends-on: #6616] #6656
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
Open
tautschnig
wants to merge
3
commits into
diffblue:develop
Choose a base branch
from
tautschnig:bugfixes/simplifier-typecast-overflow
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
regression/cbmc/gcc_builtin_add_overflow/conversion-check.c
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __GNUC__ | ||
_Bool __builtin_add_overflow(); | ||
#endif | ||
|
||
int main() | ||
{ | ||
unsigned a, b, c; | ||
if(__builtin_add_overflow(a, b, &c)) | ||
return 0; | ||
} |
10 changes: 10 additions & 0 deletions
10
regression/cbmc/gcc_builtin_add_overflow/conversion-check.desc
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE | ||
conversion-check.c | ||
--conversion-check --unsigned-overflow-check --signed-overflow-check | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^Generated [1-9]\d* VCC\(s\) | ||
-- | ||
Zero VCCs should be generated. |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <assert.h> | ||
|
||
int nondet_int(); | ||
|
||
void main() | ||
{ | ||
int a = nondet_int(); | ||
int b = nondet_int(); | ||
int c = a + | ||
#pragma CPROVER check disable "signed-overflow" | ||
(a + b); | ||
#pragma CPROVER check pop | ||
|
||
#pragma CPROVER check disable "signed-overflow" | ||
for(int i = 0; i < 10; ++i) | ||
{ | ||
int temp = a + b; | ||
#pragma CPROVER check pop | ||
int foo = temp + a; | ||
assert(foo > 2); | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
main.c | ||
--signed-overflow-check | ||
^\[main.overflow.1\] line 9 arithmetic overflow on signed \+ in a \+ a \+ b: FAILURE$ | ||
^\[main.overflow.2\] line 19 arithmetic overflow on signed \+ in temp \+ a: FAILURE$ | ||
^\[main.assertion.1\] line 20 assertion foo > 2: FAILURE$ | ||
^\*\* 3 of 3 failed | ||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
-- | ||
No assertions other than the above three are expected. |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
int main() | ||
{ | ||
char buf[10]; | ||
__CPROVER_size_t max = 9; | ||
__CPROVER_size_t start = 1; | ||
|
||
__CPROVER_assert( | ||
__CPROVER_r_ok(buf + start, max - start), "array is readable"); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
main.c | ||
--nan-check _ --signed-overflow-check --unsigned-overflow-check | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
This test doesn't actually use contracts, but rather demonstrates the workflow | ||
of having goto-instrument expand __CPROVER_r_ok (but really doing nothing else) | ||
before CBMC when may add (overflow) checks. Doing so must not result in failing | ||
assertions that would not have failed on the original input. |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible worth rewording the comment here to be super explicit?