-
Notifications
You must be signed in to change notification settings - Fork 15k
[ADT] Tighten static_assert in Bitfields #165099
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
[ADT] Tighten static_assert in Bitfields #165099
Conversation
This patch tightens the static_assert. FirstBit and LastBit are 0-based bit indices of a bitfield, so they must be strictly less than StorageBits.
|
@llvm/pr-subscribers-llvm-adt Author: Kazu Hirata (kazutakahirata) ChangesThis patch tightens the static_assert. FirstBit and LastBit are Full diff: https://github.com/llvm/llvm-project/pull/165099.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/Bitfields.h b/llvm/include/llvm/ADT/Bitfields.h
index 1fbc41c472581..be9546e9cc4cb 100644
--- a/llvm/include/llvm/ADT/Bitfields.h
+++ b/llvm/include/llvm/ADT/Bitfields.h
@@ -100,8 +100,8 @@ template <typename Bitfield, typename StorageType> struct Impl {
using IntegerType = typename Bitfield::IntegerType;
static constexpr size_t StorageBits = sizeof(StorageType) * CHAR_BIT;
- static_assert(Bitfield::FirstBit <= StorageBits, "Data must fit in mask");
- static_assert(Bitfield::LastBit <= StorageBits, "Data must fit in mask");
+ static_assert(Bitfield::FirstBit < StorageBits, "Data must fit in mask");
+ static_assert(Bitfield::LastBit < StorageBits, "Data must fit in mask");
static constexpr StorageType LowMask =
maskTrailingOnes<StorageType>(Bitfield::Bits);
static constexpr StorageType Mask = LowMask << Bitfield::Shift;
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/32187 Here is the relevant piece of the build log for the reference |
This patch tightens the static_assert. FirstBit and LastBit are 0-based bit indices of a bitfield, so they must be strictly less than StorageBits.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/41902 Here is the relevant piece of the build log for the reference |
This patch tightens the static_assert. FirstBit and LastBit are 0-based bit indices of a bitfield, so they must be strictly less than StorageBits.
This patch tightens the static_assert. FirstBit and LastBit are 0-based bit indices of a bitfield, so they must be strictly less than StorageBits.
This patch tightens the static_assert. FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.