diff options
author | Mike Frysinger <vapier@gentoo.org> | 2024-01-07 00:23:41 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2024-01-08 20:02:29 -0500 |
commit | 4223df94e038c653eab6cb39928184c3fcb2575f (patch) | |
tree | 62287fbf87ccdc11383b4d210521179f8f2dd2cd /sim | |
parent | b0c687b2ca6e5910b0494c80d01d6b48ff6f0c51 (diff) | |
download | binutils-4223df94e038c653eab6cb39928184c3fcb2575f.zip binutils-4223df94e038c653eab6cb39928184c3fcb2575f.tar.gz binutils-4223df94e038c653eab6cb39928184c3fcb2575f.tar.bz2 |
sim: sh: avoid left shifting negative values
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.
Diffstat (limited to 'sim')
-rw-r--r-- | sim/sh/gencode.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index c121d53..8246e894 100644 --- 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;", |