ubsan: cr16: left shift cannot be represented in type 'int'
authorAlan Modra <amodra@gmail.com>
Thu, 2 Jan 2020 21:42:00 +0000 (08:12 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 4 Jan 2020 08:50:33 +0000 (19:20 +1030)
* cr16-dis.c (cr16_match_opcode): Avoid shift left of signed value.

opcodes/ChangeLog
opcodes/cr16-dis.c

index 514466ed635e7b620bc5992ce44a8ff3717b1141..d72dcec0426823d60ec5e0ade4b8cfa39d3df4b8 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-04  Alan Modra  <amodra@gmail.com>
+
+       * cr16-dis.c (cr16_match_opcode): Avoid shift left of signed value.
+
 2020-01-04  Alan Modra  <amodra@gmail.com>
 
        * crx-dis.c (match_opcode): Avoid shift left of signed value.
index c40a07e2502e03ca63432066c677b68f4f4a78c7..1be67b21181d98fb882027b1b099075f2a76949c 100644 (file)
@@ -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];