-
Notifications
You must be signed in to change notification settings - Fork 14
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
Make overflow checks optional at compile time #410
Merged
Merged
Conversation
This file contains 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
If SUS_CHECK_INTEGER_OVERFLOW is defined to false then overflow checks will be removed in signed integers. Wrapping operations (as with unsigned integers) will be performed instead of Undefined Behaviour.
If SUS_CHECK_INTEGER_OVERFLOW is defined to false then overflow checks will be removed in unsigned integers. Wrapping operations will be performed for shift operations instead of Undefined Behaviour.
danakj
force-pushed
the
overflow-checks
branch
from
November 29, 2023 04:14
09a309f
to
c8bf45d
Compare
Clang caches the result of `if constexpr ()` across tests.
This avoids ODR issues where different tests cause integer methods to be instantiated differently.
Add a 16 sanitizer bot since the 17 sanitizer bot is also broken. Upstream: llvm/llvm-project#73402
danakj
force-pushed
the
overflow-checks
branch
from
November 29, 2023 15:16
6b1d775
to
8649261
Compare
danakj
force-pushed
the
overflow-checks
branch
from
November 29, 2023 15:34
23f3f4b
to
0b91993
Compare
The implementation is in unsigned_integer_impl.h and library code can't always include both due to cycles.
danakj
force-pushed
the
overflow-checks
branch
from
November 29, 2023 15:39
0b91993
to
9ce6c46
Compare
These already exist for the basic operators, but were missing for methods like checked_add, saturating_div, etc.
This reverts commit 389f5ee. The problem was ODR violations, not the use of if constexpr. =)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This allows overflow checks to be removed through a compile-time option, by defining
SUS_CHECK_INTEGER_OVERFLOW
to false.This aligns with the "arithmetic safety" profile suggested by Dr Stroustrup in "Delivering Safe C++": https://www.youtube.com/watch?v=I8UvQKvOSSw
Closes #408