https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106868
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:ad6ace70ba38d2052eeb5adb9672d33f59867be0 commit r12-8972-gad6ace70ba38d2052eeb5adb9672d33f59867be0 Author: Richard Biener <rguent...@suse.de> Date: Mon Dec 5 10:13:13 2022 +0100 tree-optimization/106868 - bogus -Wdangling-pointer diagnostic The testcase shows we mishandle the case where there's a pass-through of a pointer through a function like memcpy. The following adjusts handling of this copy case to require a taken address and adjust the PHI case similarly. PR tree-optimization/106868 * gimple-ssa-warn-access.cc (pass_waccess::gimple_call_return_arg_ref): Inline into single user ... (pass_waccess::check_dangling_uses): ... here and adjust the call and the PHI case to require that ref.aref is the address of the decl. * gcc.dg/Wdangling-pointer-pr106868.c: New testcase. (cherry picked from commit d492d50f644811327c5976e2c918ab6d906ed40c)