-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Change check for "shift > Type::BITS" to avoid offset greater than total bits. #133016
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
Conversation
@llvm/pr-subscribers-libc Author: Amy Huang (amykhuang) Changesnexttowardf16_test is resulting in calling shift and for some reason not meeting the invariant where offset is less than bits. Change the if statement to directly check if shift - 1 meets the conditions. Full diff: https://github.com/llvm/llvm-project/pull/133016.diff 1 Files Affected:
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index 16b690be08612..2378b1e594c44 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -335,7 +335,7 @@ template <size_t Bits> struct DyadicFloat {
.get_val();
MantissaType round_mask =
- shift > MantissaType::BITS ? 0 : MantissaType(1) << (shift - 1);
+ shift - 1 >= MantissaType::BITS ? 0 : MantissaType(1) << (shift - 1);
MantissaType sticky_mask = round_mask - MantissaType(1);
bool round_bit = !(mantissa & round_mask).is_zero();
|
It looks like some false-positive from the sanitizer? Shall we create an issue for them? |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/6413 Here is the relevant piece of the build log for the reference
|
nexttowardf16_test is resulting in calling shift and for some reason not meeting the invariant where offset is less than bits. Change the if statement to directly check if shift - 1 meets the conditions.