arm-none-eabi-gcc version 8 and later produce a GMP arithmetic error

Bug #1912798 reported by Titouan Coladon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

When building GMP with arm-none-eabi-gcc version 7, everything is fine.
But when using version 8, 9 or 10 the code below produces a wrong output:

    mpz_t t; mpz_init(t);
    mpz_t tt; mpz_init(tt);
    mpz_t ttt; mpz_init(ttt);
    mpz_set_str(tt,
"25975415027868818028037643145183730078267964363630309107863975221668725232906664910091356673487591948237515304861352649057814029879720636142810833722202669061030484458925649047021859875730105532595466846094449735851132072400310565642",
10);
    mpz_set_str(t,
"6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449",
10);
    mpz_mod(ttt, tt, t);
    printf("tt = "); gmp_printf("%Zd", tt); printf("\n");
    printf("t = "); gmp_printf("%Zd", t); printf("\n");
    printf("ttt = "); gmp_printf("%Zd", ttt); printf("\n");
    mpz_clear(t);
    mpz_clear(tt);
    mpz_clear(ttt);

The result is:

tt =
25975415027868818028037643145183730078267964363630309107863975221668725232906664910091356673487591948237515304861352649057814029879720636142810833722202669061030484458925649047021859875730105532595466846094449735851132072400310565642
t =
6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449
ttt =
3578942983869995381409279381784954092773488221200587338717407747084074518600438737913956360066709506626656635118978526559637095289631190671071178702312877654

but ttt should be
5247183143879283565064056089869553515440215252945038779070795247972433237341511292686962488915110675351673985513318500576097977116134885013371639187873069514

I crosscompile for a STM32F4 board.
The GMP function "mpz_probab_prime_p" is also returning a wrong result when GMP is compile with arm-none-eabi-gcc version 8, 9 or 10.

I used the binary package for linux given here: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

I have a test program to reproduce the bug, but I cannot attach anything here.

Best Regards,

Titouan Coladon

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.