-
Notifications
You must be signed in to change notification settings - Fork 273
Add __builtin_add_overflow primitives #5233
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
Add __builtin_add_overflow primitives #5233
Conversation
`cprover_library.inc` should depend on the *.c files, not just the converter itself.
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.
Looks good.
@@ -0,0 +1,80 @@ | |||
#include <limits.h> | |||
#include <assert.h> | |||
|
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.
Tests look good, but could we add a few more cases? In particular, these tests only cover some of the "easily optimised" cases (e.g value of 1, adding/subtracting to MAX/MIN), but it would be great to see some tests that also cover "mid-range value x + mid-range value y == overflow" and "slightly smaller mid-range value x + mid-range value y != overflow" cases.
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.
@chrisr-diffblue I’ve added some more cases to that end
17dbc9f
to
0de4466
Compare
Note: Not the generic version.
0de4466
to
448906f
Compare
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.
Looks good, and thanks for expanding the tests.
Codecov Report
@@ Coverage Diff @@
## develop #5233 +/- ##
===========================================
+ Coverage 67.51% 67.51% +<.01%
===========================================
Files 1161 1161
Lines 95501 95501
===========================================
+ Hits 64479 64481 +2
+ Misses 31022 31020 -2
Continue to review full report at Codecov.
|
This addresses part of #4701. Only add primitives in this PR. Note
gcc
also has a generic__builtin_add_overflow
which isn’t implemented here. The issue also has some discussion about making overflow checks faster, this also isn’t implemented here.