[llvm] r218496 - Support: Remove undefined behavior from &raw_ostream::operator<<
David Majnemer
david.majnemer at gmail.com
Thu Sep 25 19:48:14 PDT 2014
Author: majnemer
Date: Thu Sep 25 21:48:14 2014
New Revision: 218496
URL: http://llvm.org/viewvc/llvm-project?rev=218496&view=rev
Log:
Support: Remove undefined behavior from &raw_ostream::operator<<
Don't negate signed integer types in &raw_ostream::operator<<(const
FormattedNumber &FN).
Modified:
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=218496&r1=218495&r2=218496&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Sep 25 21:48:14 2014
@@ -433,7 +433,7 @@ raw_ostream &raw_ostream::operator<<(con
char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
char *CurPtr = EndPtr;
bool Neg = (FN.DecValue < 0);
- uint64_t N = Neg ? -FN.DecValue : FN.DecValue;
+ uint64_t N = Neg ? -static_cast<uint64_t>(FN.DecValue) : FN.DecValue;
while (N) {
*--CurPtr = '0' + char(N % 10);
N /= 10;
More information about the llvm-commits
mailing list