This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ubsan: ns32k: left shift cannot be represented in type 'int'
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 11 Dec 2019 13:36:23 +1030
- Subject: Re: ubsan: ns32k: left shift cannot be represented in type 'int'
- References: <20191211005738.GG32672@bubble.grove.modra.org>
Oops.
* ns32k-dis.c (sign_extend): Correct last patch.
diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c
index 5e6f0964b7..e43fff712a 100644
--- a/opcodes/ns32k-dis.c
+++ b/opcodes/ns32k-dis.c
@@ -327,8 +327,8 @@ bit_copy (bfd_byte *buffer, int offset, int count, char *to)
static int
sign_extend (unsigned int value, unsigned int bits)
{
- unsigned int sign = 1u << bits;
- return ((value & (sign - 1)) ^ sign) - sign;
+ unsigned int sign = 1u << (bits - 1);
+ return ((value & (sign + sign - 1)) ^ sign) - sign;
}
static void
--
Alan Modra
Australia Development Lab, IBM