[Bug c/65752] Too strong optimizations int -> pointer casts

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 14 10:50:00 GMT 2015


--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Robbert from comment #9)
> (In reply to Richard Biener from comment #6)
> > which fixes the testcase (but is incomplete - equivalences built on
> > gimple assignment RHS need to be considered as well).
> Can you give an example?

just do

  _Bool cmp = (i == (uintptr_t)&x);
  if (cmp) { .... }

in your original testcase (ok, optimization will probably make them equivalent,
but you can't rely on that one).

Similar for function calls

  if (equal (i, (uintptr_t)&x))) { ... }

with the obvious implementation of equal.  Or

  global = (uintptr_t)&x;
  if (equal (i)) { .... }

and see how this will make PTA useless (all pointers passed to a function
whose result might be used in a way to take advantage of an equality relation
need to be considered pointing to anything).  [and then thorougly specify
"take advantage of an equality relation"]

More information about the Gcc-bugs mailing list