Fix right shift by 64 bits detected on CXX/lex/lex.literal/lex.ext/p4.cpp
authorAlexey Samsonov <vonosmas@gmail.com>
Sat, 6 Sep 2014 00:41:19 +0000 (00:41 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Sat, 6 Sep 2014 00:41:19 +0000 (00:41 +0000)
test case on UBSan bootstrap bot.

This fixes the last failure of "check-clang" in UBSan bootstrap bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217294 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index 7989e30afae62d4cdbf4b4f552b648387f78448e..097986d3e7ccd118850e82775cd598ea824931c2 100644 (file)
@@ -3377,7 +3377,9 @@ void APFloat::makeLargest(bool Negative) {
   // internal consistency.
   const unsigned NumUnusedHighBits =
     PartCount*integerPartWidth - semantics->precision;
-  significand[PartCount - 1] = ~integerPart(0) >> NumUnusedHighBits;
+  significand[PartCount - 1] = (NumUnusedHighBits < integerPartWidth)
+                                   ? (~integerPart(0) >> NumUnusedHighBits)
+                                   : 0;
 }
 
 /// Make this number the smallest magnitude denormal number in the given