Version 4.1.4: gmp_printf() fails.

Torbjorn Granlund tege at
Tue Jan 31 18:15:04 CET 2006

Henrik Johansson <mhrkjohansson at> writes:

  The following program fails with a "Segmentation fault" when compiled
  and run on both a cygwin and a debian system.
  #include <stdio.h>
  #include <gmp.h>
  main(int argc, char *argv[])
    mpz_t res;
    mpz_init_set_ui(res, 1);
    mpz_mul_2exp(res, res, 30402457);
    mpz_sub_ui(res, res, 1);
    gmp_printf("%Zd", res);
    return 0;
This is almost surely stack overflow on your machine.
Please see Q3 under  


More information about the gmp-bugs mailing list