Very annoying mpz_get_str function Problem !

The Codrinus codrin at flynet.iasi.rdsnet.ro
Wed Nov 26 16:29:47 CET 2003


> 
> First of all, when reporting bugs/problems please include the system 
> architecture and OS you are using, as well as any non-default build 
> parameters you may have used. Whether or not and in what form the error 
> occurs may depend on the specifics of your installation.

Sorry about that. I am currently using RedHat 9.0 Shrike, and the
precompiled rpm's gmp-4.1.2-2 and gcc-3.2.2-5 from the original 
distribution.

> Now, whenever I got spurious errors leading to SEGV, core dumps, 
> incorrect results etc, it has always turned out to be an uninitialized 
> mpz_t so far. This may sound like a dumb suggestion and I apologize if 
> it does, but can you please check that every mpz_t is properly 
> initialized before use and doesn't get mpz_clear'ed somewhere etc. ?

in my function I used:

 mpz_t bignumber;
 mpz_init (bignumber);
 while (...) {
   ...
   char *string = mpz_get_str (NULL, base, bignumber);
   ...
 }
 ...
 mpz_clear (bignumber);

 The first time I got errors I used my default allocation function with 
 char *solution = new char[mpz_sizeinbase(numstr,base)+2];
 and then mpz_get_str(solution, base, bignumber);
 After that I tried to use the default gmp memory allocation with
 char *solution = mpz_get_str (NULL, base, bignumber);
 and it passed, but not for long, as the function complexity has grown.

> Alex
> 



More information about the gmp-discuss mailing list