Fix an off-by-one bug in computing the index of the word to clear.
authorReid Spencer <rspencer@reidspencer.com>
Thu, 15 Feb 2007 20:49:10 +0000 (20:49 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 15 Feb 2007 20:49:10 +0000 (20:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34326 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/BitVector.h

index 39819ee5c829cfe3590158129768fd4dc019449c..79c3f585677353e7219029879ce0c2c12190d3d4 100644 (file)
@@ -292,7 +292,10 @@ private:
   void clear_unused_bits() {
     if (Size) {
       unsigned ExtraBits = Size % BITS_PER_WORD;
-      Bits[Size / BITS_PER_WORD] &= ~(~0 << ExtraBits);
+      unsigned index = Size / BITS_PER_WORD;
+      if (Size % BITS_PER_WORD == 0)
+        index--;
+      Bits[index] &= ~(~0 << ExtraBits);
     }
   }