This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/21404] New: wrong code for array copy in while loop


This test case fails for GCC 3.3.x and GCC 3.4.x at any level of optimization
other than -O0:

extern void abort (void);
char buffer[20];
                                                                                
void foo (char *p, const char *q)
{
  int i = 0;
  while (q[i])
    p[i] = q[i++];
}
                                                                                
int
main ()
{
  foo (buffer, "howdy");
  if (buffer[0] != 'h')
    abort ();
  return 0;
}

I've tried it on powerpc64-linux and i686-linux and it fails on both.  It
doesn't fail with Red Hat's GCC 3.2.2-5 compiler (I don't have an FSF 3.2
compiler built anywhere), and doesn't fail with GCC 4.0.0 or GCC mainline.

-- 
           Summary: wrong code for array copy in while loop
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janis at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]