projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3deb3e3
)
Fix undefined behavior (left shift by 64 bits) in ScaledNumber::toString().
author
Alexey Samsonov
<vonosmas@gmail.com>
Wed, 20 Aug 2014 18:30:07 +0000
(18:30 +0000)
committer
Alexey Samsonov
<vonosmas@gmail.com>
Wed, 20 Aug 2014 18:30:07 +0000
(18:30 +0000)
This bug is reported by UBSan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216116
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Support/ScaledNumber.cpp
patch
|
blob
|
history
diff --git
a/lib/Support/ScaledNumber.cpp
b/lib/Support/ScaledNumber.cpp
index 3fe027ba33164f156a3678ee242341e70ec0cb38..fc6d4e7be43a5baaaa3667f7029eec72a3f45b7f 100644
(file)
--- a/
lib/Support/ScaledNumber.cpp
+++ b/
lib/Support/ScaledNumber.cpp
@@
-220,6
+220,9
@@
std::string ScaledNumberBase::toString(uint64_t D, int16_t E, int Width,
} else if (E > -64) {
Above0 = D >> -E;
Below0 = D << (64 + E);
+ } else if (E == -64) {
+ // Special case: shift by 64 bits is undefined behavior.
+ Below0 = D;
} else if (E > -120) {
Below0 = D >> (-E - 64);
Extra = D << (128 + E);