We do not complete structs during type merging nor do we consider types which
just differ in completeness as equal.

t1.c:
struct X;
struct Y
{
  struct X *p;
  int i;
};
void foo (struct Y *p)
{
  p->i = 1;
}

t2.c:
/* struct X is complete in this TU, this causes us to not merge Y and
   thus assign different alias-sets to them.  */
struct X
{
  int i;
};
struct Y
{
  struct X *p;
  int i;
};
extern void abort (void);
extern void foo(struct Y *);
int __attribute__((noinline)) bar(struct Y *p)
{
  p->i = 0;
  foo (p);
  return p->i;
}
int main()
{
  struct Y y;
  if (bar (&y) != 1)
    abort ();
  return;
}


just forward-declaring struct X in t2.c or compiling with -fno-strict-aliasing
fixes the issue.


-- 
           Summary: Wrong code from TBAA because not completing structs
                    during merging
           Product: gcc
           Version: lto
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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

Reply via email to