mini-gmp

Zimmermann Paul Paul.Zimmermann at inria.fr
Thu Jan 16 20:36:35 UTC 2014


       Dear Niels,

> From: nisse at lysator.liu.se (Niels Möller)
> Date: Thu, 16 Jan 2014 21:11:49 +0100
> 
> Zimmermann Paul <Paul.Zimmermann at inria.fr> writes:
> 
> > I found a bug in mini-gmp: the GMP _mpz_realloc function is defined as
> > mpz_realloc in mini-gmp (without the _ prefix):
> 
> I think this was intended as an internal function in mini-gmp, not an
> implementation of the _mpz_realloc interface. Hence declared static.

sorry, I saw that after I sent my mail...

> We could add _mpz_realloc (and add mpz_realloc2, which is the
> recommended gmp interface).
> 
> But both realloc functions would be of quite limited utility when using
> mini-gmp, because many of the functions assign the result variable
> using mpz_swap, making the caller's allocation irrelevant.
> 
> Do you depend on _mpz_realloc setting the result to zero if the value
> doesn't fit? Otherwise,
> 
>   #if WITH_MINI_GMP
>   #define _mpz_realloc(x, s)
>   #define mpz_realloc2(x, s)
>   #endif
> 
> might be a good enough substitute for mpfr (but it's not good enough, if
> we want to define it in mini-gmp).

we don't depend on _mpz_realloc setting the result to zero, but your suggestion
does not work, since for example in mpfr_get_z_2exp (mpz_ptr z, mpfr_srcptr f),
we need to make sure that z has sufficient space to store the significand of f.

Paul


More information about the gmp-bugs mailing list