ubsan: xtensa: left shift cannot be represented in type 'int'

Message ID 20191220095458.GJ32672@bubble.grove.modra.org
State New
Headers show
Series
  • ubsan: xtensa: left shift cannot be represented in type 'int'
Related show

Commit Message

Alan Modra Dec. 20, 2019, 9:54 a.m.
* xtensa-isa.c (xtensa_insnbuf_from_chars): Avoid signed overflow.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/xtensa-isa.c b/bfd/xtensa-isa.c
index 172de6f41e..9ddc6cd844 100644
--- a/bfd/xtensa-isa.c
+++ b/bfd/xtensa-isa.c
@@ -223,7 +223,7 @@  xtensa_insnbuf_from_chars (xtensa_isa isa,
       int word_inx = byte_to_word_index (i);
       int bit_inx = byte_to_bit_index (i);
 
-      insn[word_inx] |= (*cp & 0xff) << bit_inx;
+      insn[word_inx] |= (unsigned) (*cp & 0xff) << bit_inx;
     }
 }