avoid undef behavior on minint, fixing PR7783.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110114 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-08-03 16:41:24 +00:00
parent 3bababf880
commit e211cd83f0

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));