[Bug tree-optimization/45967] [4.5 Regression] gcc-4.5.x optimizes code with side-effects away

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 17 12:02:00 GMT 2011


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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |tree-optimization
      Known to fail|                            |4.5.2

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-17 11:44:11 UTC ---
The patch is quite big and a backport is nothing for the faint-hearted.  Do not
hold your breath.

The underlying problem is present since ever btw, and 4.4 can be tricked
into miscompiling with the usual avoid-empty-points-to-sets trick
(conditionally assign (not) to the pointer, thus add something else
to the set):

extern void abort (void);
int b;
void
foo (void *p_, int *q)
{
  int *p;
  int i;
  for (i = 0; i < sizeof(int *); ++i)
    ((char *)&p)[i] = ((char *)p_)[i];
  if (b)
    p = q;
  *p = 1;
}
int main()
{
  int i = 0, j;
  int *p = &i;
  foo (&p, &j);
  if (i != 1)
    abort ();
  return 0;
}

I'll add some more testcases.



More information about the Gcc-bugs mailing list