-
Notifications
You must be signed in to change notification settings - Fork 84
Fix interval division #1804
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
Merged
Merged
Fix interval division #1804
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b817c3c
Add test 39-signed-overflows/15-div-minus-1 (issue #1803)
sim642 3e1ddb4
Hacky fix for issue #1803
sim642 2a0d592
Add IntervalSetDomain.binary_op_concat_with_norm
sim642 fe3e734
Replace concat_map of singleton with map in IntervalSetDomain
sim642 b5b4d8d
Remove hacky interval join in div
sim642 fb3b89c
Simplify interval div
sim642 eccfc0e
Clean up interval div
sim642 133b6e5
Add cram test 39-signed-overflows/15-div-minus-1
sim642 a0c00fd
Fix IntervalSetDomain div overflow including 0
sim642 0c6d1af
Document interval div
sim642 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
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
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,12 @@ | ||
| // PARAM: --enable ana.int.interval | ||
| #include <limits.h> | ||
|
|
||
| int main() { | ||
| int bad = INT_MIN / -1; // WARN (overflow) | ||
| int x, y; | ||
| bad = x / y; // WARN (div by zero and overflow, distinguished in cram test) | ||
| if (y != 0) { | ||
| bad = x / y; // WARN (overflow) | ||
| } | ||
| return 0; | ||
| } |
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,20 @@ | ||
| $ goblint --enable warn.deterministic --enable ana.int.interval 15-div-minus-1.c | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:5:9-5:26) | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:7:5-7:16) | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:9:9-9:20) | ||
| [Warning][Integer > DivByZero][CWE-369] Second argument of division might be zero (15-div-minus-1.c:7:5-7:16) | ||
| [Info][Deadcode] Logical lines of code (LLoC) summary: | ||
| live: 6 | ||
| dead: 0 | ||
| total lines: 6 | ||
|
|
||
| $ goblint --enable warn.deterministic --enable ana.int.interval_set 15-div-minus-1.c | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:5:9-5:26) | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:7:5-7:16) | ||
| [Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:9:9-9:20) | ||
| [Warning][Integer > DivByZero][CWE-369] Second argument of division might be zero (15-div-minus-1.c:7:5-7:16) | ||
| [Info][Deadcode] Logical lines of code (LLoC) summary: | ||
| live: 6 | ||
| dead: 0 | ||
| total lines: 6 | ||
|
|
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,2 @@ | ||
| (cram | ||
| (deps (glob_files *.c))) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
By the way, I'm not sure why, but the old handling of division by 0 is quite inconsistent (i.e. not monotone in the second argument):
x / [0, 0]returns top (for division by 0).x / [0, 42]delegates tox / [1, 42], which doesn't return top.x / [-42, 0]delegates tox / [-42, -1], which doesn't return top.x / [-42, 42]again returns top (for division by 0).The new handling consistently returns top in all of the above cases.
Maybe the goal was to imitate the kind of split at 0 which is now part of the general logic in
IArith.div?