possible bug in mpz_init with conditional compilation __CHECKER__ enabled
Vicente Benjumea
vicente at lcc.uma.es
Tue Mar 11 16:38:22 UTC 2014
Hi,
I know this is very unlikely, but it doesn't hurt checking it.
in GMP gmp-5.1.3, in source file mpz/init.c, the last sentence of the
mpz_init function says (under conditional compilation): PTR(x) = 0;
where probably should say PTR(x)[0] = 0; as it appears in source file
mpz/init2.c
void mpz_init (mpz_ptr x)
{
ALLOC (x) = 1;
PTR (x) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
SIZ (x) = 0;
#ifdef __CHECKER__
/* let the low limb look initialized, ... */
PTR (x) = 0;
#endif
}
void mpz_init2 (mpz_ptr x, mp_bitcnt_t bits)
{
mp_size_t new_alloc;
bits -= (bits != 0); /* Round down, except if 0 */
new_alloc = 1 + bits / GMP_NUMB_BITS;
if (sizeof (unsigned long) > sizeof (int)) /* ... */
{
if (UNLIKELY (new_alloc > INT_MAX))
{
fprintf (stderr, "gmp: overflow in mpz type\n");
abort ();
}
}
PTR(x) = __GMP_ALLOCATE_FUNC_LIMBS (new_alloc);
ALLOC(x) = new_alloc;
SIZ(x) = 0;
#ifdef __CHECKER__
/* let the low limb look initialized, ... */
PTR(x)[0] = 0;
#endif
}
Hope it helps
Thank you very much
Vicente
More information about the gmp-bugs
mailing list