[Bug tree-optimization/63446] dangling reference results in confusing diagnostic from -Wuninitialized

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Oct 3 07:10:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63446

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
make_foo:

  MEM[(struct foo *)&D.2281] = &x;
  x ={v} {CLOBBER};
  return D.2281;

That doesn't seem so easy to warn about. We could walk from return to find some
of the latest non-clobbered dominating writes to that variable, then if it is
an ADDR_EXPR look for dominating clobbers, but that would be very specialized,
slight variations on this code would not warn (and all those walks may start to
get costly if we do them naively). It is easier to warn in the caller when it
tries to dereference the dangling pointer.



More information about the Gcc-bugs mailing list