On 4/14/23 17:42, Jason Merrill via Gcc-patches wrote:
Tested x86_64-pc-linux-gnu, ok for trunk?

-- 8< --

Here we hit the MEM_REF case, with its arg an ADDR_EXPR, but had no handling
for that and wrongly assumed it would be a reference to a local variable.
This patch overhauls the logic for deciding whether the target is something
to warn about so that we only warn if we specifically recognize the target
as non-local.  None of the existing tests regress as a result.

        PR c++/109514

gcc/ChangeLog:

        * gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores):
        Overhaul lhs_ref.ref analysis.

gcc/testsuite/ChangeLog:

        * g++.dg/warn/Wdangling-pointer-6.C: New test.
One might ask if we have a (MEM_REF (ADDR_REF ...)) why we didn't simplify that by removing the MEM_REF and ADDR_REF wrappers. But on the assumption there's a good reason to have such nodes, OK for the trunk.

jeff

Reply via email to