I cannot remember if I filed a bug about this or not but I noticed this while
looking at some Fortran code.  Here is testcase which shows the issue:
void link_error(void);

int *t;
int g(int *a)
{
  t = a;
  *a = 2;
}

void f(int *a)
{
  int b;
  b = 1;
  g(&b);
  b = 2;
  *a = 1;  <--- a cannot point to b here.
  if (b == 2)
    link_error();
}

int main(void)
{
  int t;
  f(&t);
  return 0;
}


-- 
           Summary: Arguments cannot alias local variables
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, alias
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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

Reply via email to