target/8213: gmp 4.1 miscompilation on x86-64
Sun Oct 13 12:46:00 GMT 2002
>Synopsis: gmp 4.1 miscompilation on x86-64
>Arrival-Date: Sun Oct 13 12:46:01 PDT 2002
>Originator: Gwenole Beauchesne
>Release: GNU C version 3.3 20020916 (experimental)
gcc-3.2 snapshots older than 2002-10-07 or earlier used to miscompile gmp 4.1 on x86-64. Reproduced with gcc3.3 2002-09-16, though it did not fully bootstrap (comparison failures in stage3) but that's not related.
Compile the following testcase with -O2, extracted from <gmp>/mpf/cmp_si.c:
int f(long x, long y)
if ((x < 0) == (y < 0))
if (x == 0)
return -(y != 0);
if (y == 0)
return x != 0;
return x >= 0 ? 1 : -1;
if (f(-1, 1) != -1)
- Add -fno-cse-follow-jumps (Andreas' hint) or lower optimizations to -O1.
- Note that s/long x/int x/ also workarounds the problem.
Does someone know which patch fixed this problem? If so, would someone mind commit it to the regression testsuite?
More information about the Gcc-bugs