avoid undef behavior on minint, fixing PR7783.

llvm-svn: 110114
This commit is contained in:
Chris Lattner 2010-08-03 16:41:24 +00:00
parent ddaaf40d24
commit 3db3bb0032
1 changed files with 3 additions and 2 deletions

View File

@ -143,9 +143,10 @@ raw_ostream &raw_ostream::operator<<(unsigned long long N) {
}
raw_ostream &raw_ostream::operator<<(long long N) {
if (N < 0) {
if (N < 0) {
*this << '-';
N = -N;
// Avoid undefined behavior on INT64_MIN with a cast.
N = -(unsigned long long)N;
}
return this->operator<<(static_cast<unsigned long long>(N));