* PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented
@ 2020-08-31 10:50 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-08-31 10:50 UTC (permalink / raw)
To: binutils
PR 26479
* config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting.
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index 467e2c9500..16695c5c06 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-31 10:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 10:50 PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).