Documentation of mpn_gcd and overlap

Niels Möller nisse at
Sun Jan 13 15:44:44 CET 2013

Marc Glisse <marc.glisse at> writes:

> I am surprised at such a no-overlap requirement between the inputs. Is
> it meant to forbid overlaps with {rp, *} instead? Or am I missing a
> reason why overlap of inputs can cause problems?

You're aware that the input areas are destroyed? They're used as working
storage during the algorithm, and things will most likely get confused
if the areas are not distinct.

I don't remember off the top of my head if overlap with rp is intended
to work, but I think it does; that area is not written to until the
algorithm terminates.

And I'm puzzled about when overlap between inputs could be useful. Do
you have an example?


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list