target/8213: gmp 4.1 miscompilation on x86-64

gbeauchesne@mandrakesoft.com gbeauchesne@mandrakesoft.com
Sun Oct 13 12:46:00 GMT 2002


>Number:         8213
>Category:       target
>Synopsis:       gmp 4.1 miscompilation on x86-64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 13 12:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Gwenole Beauchesne
>Release:        GNU C version 3.3 20020916 (experimental)
>Organization:
>Environment:
x86_64-mandrake-linux-gnu
>Description:
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.
>How-To-Repeat:
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;
    }
  else
    {
      return x >= 0 ? 1 : -1;
    }
}

int main(void)
{
  if (f(-1, 1) != -1)
    abort();

  return 0;
}
>Fix:
- 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?
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list