Bug involving GMP and mpz_urandomb

Marc Glisse marc.glisse at inria.fr
Sun Dec 23 20:24:01 CET 2012


On Sun, 23 Dec 2012, Perry Lee wrote:

> #include <gmp.h>
> int main(void)
> {
>   gmp_randstate_t rs;
>   mpz_t randNum;
>   gmp_randinit_default(rs);
>   int i;
>   for (i = 0; i < 1; ++i) /* the "1" can be any number, really */
>     mpz_urandomb(randNum, rs, 32);
>   gmp_randclear(rs);
>   return 0;
> }

You need to initialize gmp variables before using them, see the manual.

-- 
Marc Glisse


More information about the gmp-bugs mailing list