Skip to content

Commit

Permalink
avoid undef behavior on minint, fixing PR7783.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110114 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Aug 3, 2010
1 parent 3bababf commit e211cd8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Support/raw_ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit e211cd8

Please sign in to comment.