[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: UBSAN error in lib/sh/random.c:79
From: |
Steffen Nurpmeso |
Subject: |
Re: UBSAN error in lib/sh/random.c:79 |
Date: |
Sat, 07 Jan 2023 23:09:13 +0100 |
User-agent: |
s-nail v14.9.24-388-g2a4673d38e |
Andreas Schwab wrote in
<871qo6f90g.fsf@igel.home>:
|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).
Seems to me that even twenty years ago gcc turned many divisions
into multiplications if it could. (Which always stunned me as
a non-mathematician.)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Re: UBSAN error in lib/sh/random.c:79, Chet Ramey, 2023/01/10