Latest commit introduces undefined behavior in hgcd2.c

Torbjörn Granlund tg at gmplib.org
Wed Sep 18 20:02:26 UTC 2019


nisse at lysator.liu.se (Niels Möller) writes:

  Is it reasonable to change it to

    #define LIMB_SHIFT_MASK (GMP_LIMB_BITS - 1)
    dh = (dh << dcnt) + (-(dcnt > 0) & (dl >> (LIMB_SHIFT_MASK & - dcnt)));

Or simply:

  dh = (dh << dcnt) + (dl >> (GMP_LIMB_BITS - 1 - dcnt) >> 1);


-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-bugs mailing list