From baeb994f3f6bf2b416676ad269f262675ab9d774 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 31 Aug 2020 15:51:24 +0930 Subject: 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(-) (limited to 'gas') diff --git a/gas/ChangeLog b/gas/ChangeLog index 3d696a9..3f615cf 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,10 @@ 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 PR 26473 PR 26474 diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c index 467e2c9..16695c5 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; } -- cgit v1.1