[Bug tree-optimization/83141] New: SRA and memcpy folding interact badly generating wrong-code

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 24 11:24:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83141

            Bug ID: 83141
           Summary: SRA and memcpy folding interact badly generating
                    wrong-code
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

/* { dg-do run } */

struct A { short s; long i; long j; };
struct A a, b;
void foo ()
{
  struct A c;
  __builtin_memcpy (&c, &b, sizeof (struct A));
  __builtin_memcpy (&a, &c, sizeof (struct A));
}
int main()
{
  __builtin_memset (&b, 0, sizeof (struct A));
  b.s = 1;
  __builtin_memcpy ((char *)&b + sizeof (short), &b, sizeof (short));
  foo ();
  __builtin_memcpy (&a, (char *)&a + sizeof (short), sizeof (short));
  if (a.s != 1)
    __builtin_abort ();
  return 0;
}


More information about the Gcc-bugs mailing list