mpz_out_str bug?: call mpz_out_str abortion on windows

仙人 月窟 goldenspider2008 at yahoo.com.cn
Wed Jun 15 05:15:48 CEST 2011


Hello,
I use the mingw +msys to compile latest  gmp-5.0.2 or gmp-5.0.1 to generate dll. Unfortunately, 
when I call mpz_out_str() , it generates an exception on windows. But mpz_get_str() run OK.
code:
 
/*mingw+msys compile  gmp-5.0.2.dll call test */
        #include <stdio.h>
        #include "gmp.h"
        #pragma  comment(lib,"libgmp-3.lib")
        int main (void)
        { 
           FILE *f=fopen("a.txt","w");
           int num=50,i;
           
           mpz_t n,m,c,r;
           char qq[100];
           
           for(i=0;i<100;i++)
               qq[i]='\0';
           mpz_init_set_str (n, "13703703579", 10);
           mpz_init_set_str (m, "29012345415", 10);          
           mpz_inits(c,r,'\0');
           mpz_gcd(c,n,m);
           mpz_fac_ui(r,num);             
   
           gmp_printf ("gcd(%Zd,%Zd) = %Zd\n\n%d! =%Zd:\n in base 16:\t",n,m,c,num,r);
//*************************** 
           //mpz_out_str(stdout,16,r);     //<---error Abort (windows XP or windows 7) ----
           //mpz_out_str(f,16,r);      //<---error Abort (windows XP or windows 7) ----
           
           //**Replacement**
           mpz_get_str(qq,16,r);//The base may vary from 2 to 36 .  run OK.
           printf("%s",qq);//console output
           i=0;
           while(qq[i]!=0)
            fputc(qq[i++],f);
           fclose(f);
//*************************** 
           mpz_clears(m,n,c,r,'\0');
       return 0;
     }
 
 
 
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmp-5.0.2_dll.zip
Type: application/x-zip-compressed
Size: 270047 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20110615/c83595b0/attachment-0001.bin>


More information about the gmp-bugs mailing list