From baeb994f3f6bf2b416676ad269f262675ab9d774 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 31 Aug 2020 15:51:24 +0930 Subject: [PATCH] PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented PR 26479 * config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting. --- gas/ChangeLog | 5 +++++ gas/config/tc-nios2.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 3d696a9d75b..3f615cf8304 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2020-08-31 Alan Modra + + PR 26479 + * config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting. + 2020-08-31 Alan Modra PR 26472 diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c index 467e2c95003..16695c5c063 100644 --- a/gas/config/tc-nios2.c +++ b/gas/config/tc-nios2.c @@ -238,10 +238,10 @@ md_chars_to_number (char *buf, int n) val = 0; if (target_big_endian) for (i = 0; i < n; ++i) - val = val | ((buf[i] & 0xff) << 8 * (n - (i + 1))); + val = val | ((valueT) (buf[i] & 0xff) << 8 * (n - (i + 1))); else for (i = 0; i < n; ++i) - val = val | ((buf[i] & 0xff) << 8 * i); + val = val | ((valueT) (buf[i] & 0xff) << 8 * i); return val; } -- 2.30.2