From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 111713875A24; Mon, 25 Jul 2022 16:10:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 111713875A24 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105867] [12/13 Regression] incorrect dangling-pointer warning Date: Mon, 25 Jul 2022 16:10:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc priority Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2022 16:10:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105867 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Priority|P3 |P2 --- Comment #2 from Richard Biener --- Confirmed. I don't know how the dataflow of the diagnostic is implemented = but to fix this it would need to go backwards from function exits and maintain a set of "killed" locations it would not diagnose in earlier code. Of course it's difficult in general considering global =3D &local; tem =3D global; other_global =3D tem; global =3D NULL; and here &local escapes to other_global but we'd have to either rely on optimization forwarding &local to tem or we'd have to conservatively assume escaping (what the current code seems to do). The former gets you false negatives while the latter false positives. Note for the testcase the store we diagnose is not dead since it has possible uses via function calls also getting 'this', so optimization is of no help in avoiding the false positive here.=