From b5aabee33073068f1f6bb71c1da9000b03b16181 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 15 Feb 2007 21:38:15 +0000 Subject: [PATCH] Proper fix for the off-by-one bug in clear_unused_bits(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34328 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/BitVector.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 79c3f585677..269621313fa 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -290,12 +290,10 @@ private: // Clear the unused top bits in the high word. void clear_unused_bits() { - if (Size) { - unsigned ExtraBits = Size % BITS_PER_WORD; + unsigned ExtraBits = Size % BITS_PER_WORD; + if (ExtraBits) { unsigned index = Size / BITS_PER_WORD; - if (Size % BITS_PER_WORD == 0) - index--; - Bits[index] &= ~(~0 << ExtraBits); + Bits[index] &= ~(~0L << ExtraBits); } }