Likely GMP bug

Torbjörn Granlund tg at
Mon May 28 09:34:01 UTC 2018

"Marco Bodrato" <bodrato at> writes:

  It was hard, but we got it:


It really worries me that our crazy broad testing did not catch this
until now.  This makes me much less confident about GMP's correctness,

I realise that a plain assembly enabled build will not trigger this for
any current platform, so few people will be afffected in practice.

  The bug is triggered not only for 32-bit limbs, but also for other sizes.
  On any machine, if the undefined behaviour is not the one we hope,

  ./configure --disable-assembly && make
  make check TESTS= && tests/mpz/t-gcd_ui

  should fail.
  It does, with ABI=64 on shell.

  Of course I also healed the bug, to avoid too many red lines in the next
  "GMP testing status": .
  This is just a workaround, waiting for a code reorganisation by someone
  who knows better than me the various algorithm alternatives.

Replacement code should not jump into loops.  This bug (but not the
shortcoming of the test suite) should teach us that lesson.

Please encrypt, key id 0xC8601622

More information about the gmp-bugs mailing list