Problem with gmp_randinit_set

sisyphus1 at sisyphus1 at
Mon Feb 13 23:38:53 UTC 2017


The following program crashes for me on MS Windows 7, gmp-6.1.2, when the 
line "gmp_randseed_ui(b, 123456);" is executed.
I built gmp in the MSYS2 shell using gcc version 5.3.0 
(x86_64-posix-sjlj-rev0, Built by MinGW-W64 project).

Configure command was:

CC="gcc -D__USE_MINGW_ANSI_STDIO" --enable-static --disable-shared --enable-assembly 
CPPFLAGS=-IC:/_64/msys_530/1.0/local/include --prefix=C:/_64/msys_530/1.0/local

#include <stdio.h>
#include <gmp.h>

int main(void) {
  gmp_randstate_t a, b;
  /* gmp_randseed_ui(a, 123456); *//* same result with or without this line 
  gmp_randinit_set(b, a);
  /* printf("%s\n", gmp_version); *//* outputs 6.1.2 */
  gmp_randseed_ui(b, 123456); /* crashes */

  return 0;


AFAICT this is a gmp bug, but I don't rule out the possibility that it's a 
user bug.

If "a" is initialised with either gmp_randinit_lc_2exp() or 
gmp_randinit_lc_2exp_size() there is no crash.


More information about the gmp-bugs mailing list