On 12/18/2009 06:27 AM, Jean Christophe Beyler wrote:
Actually, I just finished updating my 4.3.2 to 4.3.3 and tested it and
I still have the same issue.
This seems to be a problem more than "just" 4.3.2.
Here is the test program:
#include<stdio.h>
#include<gmp.h>
int main() {
mpz_t a,b;
mpz_init_set_str(a, "10000000000", 10); // program works with 10^9, but not
// with 10^10 (10^20> 2^64)
mpz_init_set(b, a);
mpz_mul(a, a, a);
gmp_printf("first, in GMP mpz_mul(a,a,a) with a=%Zd gives %Zd \n", b, a);
mpz_set(b, a);
mpz_mul(a, a, a);
gmp_printf("second, in GMP mpz_mul(a,a,a) with a=%Zd gives %Zd \n", b, a);
return 0;
}
We obtain:
first, in GMP mpz_mul(a,a,a) with a=10000000000 gives 100000000000000000000
second, in GMP mpz_mul(a,a,a) with a=100000000000000000000 gives
22545360131605409929222215637663717291581095979492475463214517286840718852096
Which clearly is wrong for the second output.
This was tested with a 64 bit architecture. I know that with a 4.1.1
port of the compiler, I do not see this issue.
I will see if I can port it forward to see if I still see the problem
but it might be difficult to port from 4.3.2 to 4.4.2, I'm not sure
how many things have changed but I'm sure quite a bit !
This is the -v of my GCC, version 4.3.3:
Using built-in specs.
Target: myarch64-linux-elf
Configured with:
/home/beyler/myarch64/src/myarch64-gcc-4.3.2/configure
--target=myarch64-linux-elf
--with-headers=/home/beyler/myarch64/src/newlib-1.16.0/newlib/libc/include
--prefix=/home/beyler/myarch64/local --disable-nls
--enable-languages=c --with-newlib --disable-libssp
--with-mpfr=/home/beyler/myarch64/local
Thread model: single
gcc version 4.3.3 (GCC)
What's myarch64? I got the correct result for your test with vanilla
gcc-4.3.2 and gmp-4.3.1 on Debian unstable AMD64.
Jie