This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: s12z: 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 11:28:30 +1030
- Subject: ubsan: s12z: left shift cannot be represented in type 'int'
* s12z-opc.c (z_decode_signed_value): Avoid signed overflow.
diff --git a/opcodes/s12z-opc.c b/opcodes/s12z-opc.c
index 3e0c0e0582..044c72a21c 100644
--- a/opcodes/s12z-opc.c
+++ b/opcodes/s12z-opc.c
@@ -410,9 +410,7 @@ z_decode_signed_value (struct mem_read_abstraction_base *mra, int offset,
int i;
uint32_t value = 0;
for (i = 0; i < size; ++i)
- {
- value |= buffer[i] << (8 * (size - i - 1));
- }
+ value = (value << 8) | buffer[i];
if (buffer[0] & 0x80)
{
--
Alan Modra
Australia Development Lab, IBM