gmp_gcdext method on 32bit vs 64 bit machines

Emmanuel Thomé Emmanuel.Thome at gmail.com
Fri Apr 29 23:36:27 CEST 2011


On Fri, Apr 29, 2011 at 04:54:18PM -0400, Waiki Wright wrote:
>   mpz_init_set_d(B,23434293864345);

I was just about to say ``you sure know about compiler warnings, don't
you ?''.

truffe /tmp $ gcc-4.4 -m32 -W -Wall zozo.c -lgmp
zozo.c: In function ‘main’:
zozo.c:8: warning: integer constant is too large for ‘long’ type
zozo.c:9: warning: integer constant is too large for ‘long’ type

However it very much seems that gcc-4.5 now silently drops this warning
(I tested 4.5.1 and 4.5.2, but with the 32-bit ABI of my 64-bit laptop).
While your mistake is pretty obvious, I am slightly amazed to see that
this potentially useful warning for a silly mistake is no longer emitted.

You might want to file a bug for gcc (please search the BTS first to see
if it hasn't been reported already).

Regards,

E.

>   mpz_init(S);
>   mpz_init(T);
>   mpz_init(G);
>   mpz_gcdext(G,S,T,A,B);
> 
>   mpz_out_str(stdout, 10, G);
>   printf("\n");
>   mpz_out_str(stdout, 10, S);
>   printf("\n");
>   mpz_out_str(stdout, 10, T);
>   printf("\n");
> 
>   return 0;
> }
> 
> On a 32 bit machine, the returned g,s,t are: 195, -4760039754357, 6965866288
> On a 64 bit machine, the returned g,s,t are: 195, -20983781660442,
> 30707772373
> 
> On the 32 bit machine, I am using: gmp-4.3.1, gcc version is 4.5.1
> and the "uname -a" is:
> Linux oc2517815826.ibm.com 2.6.35.9-64.fc14.i686 #1 SMP Fri Dec 3
> 12:35:42 UTC 2010 i686 i686 i386 GNU/Linux
> 
> On the 64 bit machine, I am using: gmp-4.3.1, gcc version is 4.5.1
> and the "uname -a" is:
> Linux oc0144164261.ibm.com 2.6.35.9-64.fc14.x86_64 #1 SMP Fri Dec 3
> 12:19:41 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
> 
> The question is why the values of s and t are different on 32 bit
> and 64 bit machines?
> 
> Thanks!
> 
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss


More information about the gmp-discuss mailing list