bug in mpz_urandomm

Torbjorn Granlund tg at swox.com
Thu Mar 12 19:57:57 CET 2009


Pierrick Gaudry <pierrick.gaudry at gmail.com> writes:

  Section 3.4 of the manual says:
    " GMP lets you use the same variable for both input and output in one
    call."
    
  And in Section 5.13, there is no exception for mpz_urandomm(). However
  the implementation (in 4.2.4, at least), does not allow the first
  parameter (the result) to be the third one (the bound). See for instance
  the line 72 of mpz/urandomm.c that compares n and rp, but n can be
  clobbered just the line before, if it's an alias to rp.
  
  So I think this is a bug in the code, or in the documentation (I have no
  objection to mpz_urandomm() not allowing aliases, but this should be
  mentioned).
  
Thanks for this bug report!

I will fix the code, since an arbitrary exception to the overlap rule
would be somewhat unhelpful, I think.

(I thought mopz/reuse.c tested all functions for this, but apparently it
does not.  I'll fix that too.)

-- 
Torbjörn


More information about the gmp-bugs mailing list