From: Alan Modra Date: Wed, 11 Dec 2019 02:41:07 +0000 (+1030) Subject: Re: ubsan: ns32k: left shift cannot be represented in type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5afa80e9a8e6585eeaac44ca51be9c6b2471bf80;p=binutils-gdb.git Re: ubsan: ns32k: left shift cannot be represented in type * ns32k-dis.c (sign_extend): Correct last patch. --- diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index c1fce7f33cc..5345dfb2bf7 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2019-12-11 Alan Modra + + * ns32k-dis.c (sign_extend): Correct last patch. + 2019-12-11 Alan Modra * vax-dis.c (NEXTLONG): Avoid signed overflow. diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c index 5e6f0964b7a..e43fff712ab 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