This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: cr16: left shift cannot be represented in type 'int'
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 4 Jan 2020 19:22:18 +1030
- Subject: ubsan: cr16: left shift cannot be represented in type 'int'
* cr16-dis.c (cr16_match_opcode): Avoid shift left of signed value.
diff --git a/opcodes/cr16-dis.c b/opcodes/cr16-dis.c
index c40a07e250..1be67b2118 100644
--- a/opcodes/cr16-dis.c
+++ b/opcodes/cr16-dis.c
@@ -319,8 +319,7 @@ cr16_match_opcode (void)
{
unsigned long mask;
/* The instruction 'constant' opcode doesn't exceed 32 bits. */
- unsigned long doubleWord = (cr16_words[1]
- + (cr16_words[0] << 16)) & 0xffffffff;
+ unsigned long doubleWord = cr16_words[1] + ((unsigned) cr16_words[0] << 16);
/* Start searching from end of instruction table. */
instruction = &cr16_instruction[NUMOPCODES - 2];
--
Alan Modra
Australia Development Lab, IBM