projects
/
binutils-gdb.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8c68d88
)
ubsan: undefined shift in sign_extend
author
Alan Modra
<amodra@gmail.com>
Sat, 13 Aug 2022 04:37:31 +0000
(14:07 +0930)
committer
Alan Modra
<amodra@gmail.com>
Sat, 13 Aug 2022 04:41:27 +0000
(14:11 +0930)
* libhppa.h (sign_extend): Avoid undefined behaviour.
bfd/libhppa.h
patch
|
blob
|
history
diff --git
a/bfd/libhppa.h
b/bfd/libhppa.h
index 1de2d5c943b58305f7fed1996ce4f3dec34a7e8b..ebaffe66abf811b7c805d0b32b02c7bdaf45692e 100644
(file)
--- a/
bfd/libhppa.h
+++ b/
bfd/libhppa.h
@@
-162,7
+162,7
@@
enum hppa_reloc_expr_type_alt
static inline unsigned ATTRIBUTE_UNUSED
sign_extend (unsigned x, unsigned len)
{
- unsigned signbit = (1 << (len - 1));
+ unsigned signbit = (1
u
<< (len - 1));
unsigned mask = (signbit << 1) - 1;
return ((x & mask) ^ signbit) - signbit;
}