Simple test case:

unsigned n;

void foo (unsigned *p)
{
  n = 4;
  *p = 0;
  if (n != 0)
    abort ();
}

main ()
{
  foo (&n);
  return 0;
}

Tested cross-compiling for MIPS, also verified that x86 also has the same
problem.
attached dump from the fre pass.
**** basically n.0_4 should not be assigned the value of 4, since *p can alias
it.

;; Function foo (foo)

Created value VH.0 for p_3
exp_gen[0] := {  }
tmp_gen[0] := { p_3 (VH.0)  }
avail_out[0] := { p_3 (VH.0)  }
exp_gen[2] := {  }
tmp_gen[2] := {  }
avail_out[2] := { p_3 (VH.0)  }
exp_gen[3] := {  }
tmp_gen[3] := {  }
avail_out[3] := { p_3 (VH.0)  }
exp_gen[4] := {  }
tmp_gen[4] := {  }
avail_out[4] := { p_3 (VH.0)  }
exp_gen[1] := {  }
tmp_gen[1] := {  }
avail_out[1] := {  }
Replaced n with 4 in n.0_4 = n;
foo (p)
{
  unsigned int n.0;

<bb 2>:
  n = 4;
  *p_3 = 0;
  n.0_4 = 4;                                    *****
  if (n.0_4 != 0) goto <L0>; else goto <L1>;

<L0>:;
  abort ();

<L1>:;
  return;

}


-- 
           Summary: Aliasing failure during tree fre
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: davidu at mips dot com


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

Reply via email to