public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: tc-z80.c:3656 shift exponent 32 is too large
@ 2020-09-02  8:42 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-09-02  8:42 UTC (permalink / raw)
  To: binutils

	* config/tc-z80.c (is_overflow): Avoid too large shift.

diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 45fcd6fbf7..2e17d00552 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -3653,7 +3653,7 @@ md_assemble (char *str)
 static int
 is_overflow (long value, unsigned bitsize)
 {
-  long fieldmask = (1UL << bitsize) - 1;
+  long fieldmask = (2UL << (bitsize - 1)) - 1;
   long signmask = ~fieldmask;
   long a = value & fieldmask;
   long ss = a & signmask;
-- 
Alan Modra
Australia Development Lab, IBM


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-02  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02  8:42 ubsan: tc-z80.c:3656 shift exponent 32 is too large 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).