We generate bad code for the following test case using the latest 4.1 compiler.
 It compiles and runs fine using 4.2.  It also compiles and runs fine with my
3.3.3 system compiler.  I've tested this on both x86_64 and ppc64 systems, and
the test case fails for both when compiled as a 32-bit app and passes when
compiled as a 64-bit app.

#include <stdio.h>

int tar (int i)
{
  printf("expected = %d, actual = %d\n", 36863, i);
  return -1;
}

void bug(int q, int bcount)
{
  int j = 0;
  int outgo = 0;

  while(j != -1)
    {
      outgo++;
      if (outgo > q-1)
        outgo = q-1;
      j = tar (outgo*bcount);
    }
}

int main(void)
{
  bug(5, 36863);
  return 0;
}

[EMAIL PROTECTED]:~> gcc-4.1.2 -O2 bug01.c
[EMAIL PROTECTED]:~> ./a.out
expected = 36863, actual = 184315


-- 
           Summary: Wrong code for simple loop test case
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bergner at vnet dot ibm dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28970

Reply via email to