mpn_perfect_square_p requires normalised input?

David Harvey dmharvey at
Mon Sep 20 19:57:09 CEST 2010

In GMP 5.0.1, it appears that mpn_perfect_square_p requires the input  
to be normalised, i.e. the high limb is not allowed to be zero, but  
this is not documented. If called with a zero high limb, and the  
residue tests fail to rule out the input being a non-square, then  
control is passed immediately to mpn_sqrtrem, which requires  
normalised input (typical result is a segfault).


More information about the gmp-bugs mailing list