[llvm] WordPos should be less than BITWORDS_PER_ELEMENT (PR #142959)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 06:00:12 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Swayam (SwayamInSync)
<details>
<summary>Changes</summary>
Bits is declared as:
```
BitWord Bits[BITWORDS_PER_ELEMENT];
```
The change modifies an assert condition to ensure that `WordPos` is strictly less than `BITWORDS_PER_ELEMENT` rather than less than or equal to it.
---
Full diff: https://github.com/llvm/llvm-project/pull/142959.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/SparseBitVector.h (+1-1)
``````````diff
diff --git a/llvm/include/llvm/ADT/SparseBitVector.h b/llvm/include/llvm/ADT/SparseBitVector.h
index 7151af6146e6e..3fec695c6e461 100644
--- a/llvm/include/llvm/ADT/SparseBitVector.h
+++ b/llvm/include/llvm/ADT/SparseBitVector.h
@@ -152,7 +152,7 @@ template <unsigned ElementSize = 128> struct SparseBitVectorElement {
unsigned WordPos = Curr / BITWORD_SIZE;
unsigned BitPos = Curr % BITWORD_SIZE;
BitWord Copy = Bits[WordPos];
- assert(WordPos <= BITWORDS_PER_ELEMENT
+ assert(WordPos < BITWORDS_PER_ELEMENT
&& "Word Position outside of element");
// Mask off previous bits.
``````````
</details>
https://github.com/llvm/llvm-project/pull/142959
More information about the llvm-commits
mailing list