[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: UBSAN error in lib/sh/random.c:79
From: |
Andreas Schwab |
Subject: |
Re: UBSAN error in lib/sh/random.c:79 |
Date: |
Sat, 07 Jan 2023 20:18:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
On Jan 07 2023, Greg Wooledge wrote:
> The variable l is a modulus, so its largest possible value is 127772.
> If the code simply said "l = ret % 127773;" then it wouldn't even be
> an issue. But the % was rewritten, presumably for efficiency.
Presumably the assumption was that two divides are more costly than a
divide and a multiply (although nowadays, compilers will try to combine
the two divides if the target architecture has a divmod insn).
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Re: UBSAN error in lib/sh/random.c:79, Chet Ramey, 2023/01/10