another? nails double bug

Torbjorn Granlund tg at
Sun Nov 16 22:57:12 CET 2008

jason at writes:

  gcc 4.2.3
  gmp-4.2.4 + 2patches
  configure --enable-assert --enable-nails=8 && make && make check
  in the mpq tests
  t-get_d FAILS
  check random test 187: bad mpq_set_d results
  32-8=24 !< 24 single prec   WHY???
  I have no idea if this is the same bug as before , just feels like it!!!!
Thanks for this bug report!

It is a different problem from the previous ones you have reported,

This time it is a limitation in mpn/generic/get_d.c.  It tries to
assembly a double mantissa from just three (24-bit) limbs, when 4 is
required.  For 32-bit machines, nail sizes greater than 6 will not work

(It might be counter intuitive that 4 limbs are needed for a 53 bit
value.  It is because of that the value might be arbitrarily aligned.
The most significant limb might have just one bit, the 2nd most
significant and and the 3rd most significant will have 24 bits each, for
49 in total, i.e. < the required 53.  With a 6-bit nail, the limbs will
have 26 bits each, and 1+26+26 >= 53.)

We're generalizing the nails support for the next GMP release, and this
problem was fixed with a rewrite of mpn/generic/get_d.c last year.

I will not patch this for GMP 4.2, since a patch would risk breaking
things for common configurations, and since nails are considered

Of course, it would have been nice if configure refused to allow these
bad configurations.  :-)


More information about the gmp-bugs mailing list