[llvm] r217294 - Fix right shift by 64 bits detected on CXX/lex/lex.literal/lex.ext/p4.cpp

Alexey Samsonov vonosmas at gmail.com
Fri Sep 5 17:41:19 PDT 2014


Author: samsonov
Date: Fri Sep  5 19:41:19 2014
New Revision: 217294

URL: http://llvm.org/viewvc/llvm-project?rev=217294&view=rev
Log:
Fix right shift by 64 bits detected on CXX/lex/lex.literal/lex.ext/p4.cpp
test case on UBSan bootstrap bot.

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

Modified:
    llvm/trunk/lib/Support/APFloat.cpp

Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=217294&r1=217293&r2=217294&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Fri Sep  5 19:41:19 2014
@@ -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





More information about the llvm-commits mailing list