mpz_gcd_ui(NULL, ...) with small limbs

Marc Glisse marc.glisse at inria.fr
Sat Jan 22 23:40:03 CET 2022


Hello,

the documentation for mpz_gcd_ui(rop, op1, op2) says "If rop is not NULL, 
store the result there." and indeed the main code contains two tests "if 
(w != NULL)". However, mpz_gcd_ui also contains special code for the case 
where op2 (an unsigned long) does not fit in a limb. And that code calls 
mpz_gcd without checking if the first argument is NULL. That probably does 
not affect any platform, since nails are not supported and I don't see 
anything defining __GMP_SHORT_LIMB.

-- 
Marc Glisse


More information about the gmp-bugs mailing list