From: Evan Cheng Date: Thu, 15 Feb 2007 21:38:15 +0000 (+0000) Subject: Proper fix for the off-by-one bug in clear_unused_bits(). X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b5aabee33073068f1f6bb71c1da9000b03b16181;p=oota-llvm.git 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 --- 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); } }