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

            Bug ID: 86492
           Summary: [8/9 Regression] store-merging wrong-code
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

union U
{
  unsigned int r;
  struct
  {
    unsigned int a:12;
    unsigned int b:4;
    unsigned int c:16;
  } f;
};

__attribute__((noinline, noclone)) unsigned int
foo (unsigned int x)
{
  union U r;
  r.r = 0;
  r.f.c = x;
  r.f.b = 0xe;
  return r.r;
}

int
main ()
{
  volatile unsigned int x;
  x = 0x72;
  x = foo (x);
  union U r;
  r.r = x;
  if (r.f.a != 0 || r.f.b != 0xe || r.f.c != 0x72)
    __builtin_abort ();
  return 0;
}

is miscompiled by store-merging at -O2.

Reply via email to