projects
/
platform
/
upstream
/
binutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b0c687b
)
sim: sh: avoid left shifting negative values
author
Mike Frysinger
<vapier@gentoo.org>
Sun, 7 Jan 2024 05:23:41 +0000
(
00:23
-0500)
committer
Mike Frysinger
<vapier@gentoo.org>
Tue, 9 Jan 2024 01:02:29 +0000
(20:02 -0500)
We just want to create a bitmask here, so cast the mask to unsigned
to avoid left shifting a negative value which is undefined behavior.
sim/sh/gencode.c
patch
|
blob
|
history
diff --git
a/sim/sh/gencode.c
b/sim/sh/gencode.c
index
c121d53
..
8246e89
100644
(file)
--- a/
sim/sh/gencode.c
+++ b/
sim/sh/gencode.c
@@
-2350,7
+2350,7
@@
static op ppi_tab[] =
" res = 31;",
"do",
" {",
- " if (Sx &
~0 << i
)",
+ " if (Sx &
((unsigned)~0 << i)
)",
" {",
" res -= i;",
" Sx >>= i;",
@@
-2373,7
+2373,7
@@
static op ppi_tab[] =
"res = 31;",
"do",
" {",
- " if (Sy &
~0 << i
)",
+ " if (Sy &
((unsigned)~0 << i)
)",
" {",
" res -= i;",
" Sy >>= i;",