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)

Jc

PS: I have already asked the gmp bug mailing list to see if they have
any input on this.


On Thu, Dec 17, 2009 at 6:19 AM, Jay Foad <jay.f...@gmail.com> wrote:
> If it's the bug being discussed here:
>
> http://gmplib.org/list-archives/gmp-discuss/2009-April/003717.html
>
> ... then it was reported as fixed here:
>
> http://gcc.gnu.org/ml/gcc/2009-04/msg00562.html
>
> Jay.
>

Reply via email to