... causes invalid removal of memory write.  The following test-case will be
committed as gcc.c-torture/execute/prXXXXXX-1.c; it is miscompiled at -O2.
The first assignment to **ipp is removed in .flow2.  This bug has been there
since at least 3.2.1.

void f (int **, int *, int *, int **, int **) __attribute__ ((__noinline__));
void
f (int **ipp, int *i1p, int *i2p, int **i3, int **i4)
{
  **ipp = *i1p;
  *ipp = i2p;
  *i3 = *i4;
  **ipp = 99;
}

extern void exit (int);
extern void abort (void);

int main (void)
{
  int i = 42, i1 = 66, i2 = 1, i3 = -1, i4 = 55;
  int *ip = &i;
  int *i3p = &i3;
  int *i4p = &i4;
  
  f (&ip, &i1, &i2, &i3p, &i4p);
  if (i != 66 || ip != &i2 || i2 != 99 || i3 != -1 || i3p != i4p || i4 != 55)
    abort ();
  exit (0);
}

-- 
           Summary: Missed invalidation of known memory contents in flow2...
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hp at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: cris-*


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

Reply via email to