Re: Unsigned integer overflow in `toom_eval_pm2.c`

2023-09-03 Thread Andrew Teylu
On Sun, Sep 3, 2023 at 7:16 PM Torbjörn Granlund wrote: > > Andrew Teylu writes: > > When I run `multiply.c` from gmpbench [https://gmplib.org/gmpbench], > I'm seeing an unsigned integer overflow in `toom_eval_pm2.c` on this > line: > > neg ^= ((k & 1) -

Unsigned integer overflow in `toom_eval_pm2.c`

2023-09-03 Thread Andrew Teylu
Hi, I'm working with gmp-6.3.0 compiled with clang 16 and its `-fsanitize=integer` flag. When I run `multiply.c` from gmpbench [https://gmplib.org/gmpbench], I'm seeing an unsigned integer overflow in `toom_eval_pm2.c` on this line: ``` neg ^= ((k & 1) - 1) ``` The values we're normally

Re: Unsigned integer overflow in `toom_eval_pm2.c`

2023-09-03 Thread Andrew Teylu
On Sun, Sep 3, 2023 at 9:16 PM Niels Möller wrote: > Does it make any difference if you change the "1" constants to "1u" ? > I'll try this in the morning and see if the runtime error goes away or not. > I see no good reason to involve any signed values here, though. Maybe > the variable neg,

Re: Unsigned integer overflow in `toom_eval_pm2.c`

2023-09-04 Thread Andrew Teylu
On Sun, Sep 3, 2023 at 11:40 PM wrote: > I attach a possible patch. > As an outsider, does it make sense to also change instances of "neg" to be "sign" (if that's the interpretation) for consistency? For someone who isn't literate in the GMP code, neg vs. sign seems to be used slightly