llvm.org GIT mirror llvm / 90406e1
Avoid undefined behavior in signed integer negation. Patch by Ahmed Charles. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141905 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 8 years ago
1 changed file(s) with 2 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
120120 raw_ostream &raw_ostream::operator<<(long N) {
121121 if (N < 0) {
122122 *this << '-';
123 N = -N;
123 // Avoid undefined behavior on LONG_MIN with a cast.
124 N = -(unsigned long)N;
124125 }
125126
126127 return this->operator<<(static_cast(N));