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

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #2)
> 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.

At some moment (in dcce1), gcc decides that x = 4 is not needed. For the same
reason, it could realize that MEM[(struct foo *)&D.2281] = &x must produce a
dangling reference, no?

Reply via email to