projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
8e4d042
)
Avoid undefined behavior in signed integer negation. Patch by Ahmed Charles.
author
Eli Friedman
<eli.friedman@gmail.com>
Thu, 13 Oct 2011 22:49:56 +0000
(22:49 +0000)
committer
Eli Friedman
<eli.friedman@gmail.com>
Thu, 13 Oct 2011 22:49:56 +0000
(22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141905
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Support/raw_ostream.cpp
patch
|
blob
|
history
diff --git
a/lib/Support/raw_ostream.cpp
b/lib/Support/raw_ostream.cpp
index c9cf249500d62064ca816bac2467205f0a93928e..4927e9a7b9d46a8bbded38eecbd3262aea51ffb0 100644
(file)
--- a/
lib/Support/raw_ostream.cpp
+++ b/
lib/Support/raw_ostream.cpp
@@
-121,7
+121,8
@@
raw_ostream &raw_ostream::operator<<(unsigned long N) {
raw_ostream &raw_ostream::operator<<(long N) {
if (N < 0) {
*this << '-';
- N = -N;
+ // Avoid undefined behavior on LONG_MIN with a cast.
+ N = -(unsigned long)N;
}
return this->operator<<(static_cast<unsigned long>(N));