From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 287EC3857C76; Tue, 18 Jan 2022 16:49:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 287EC3857C76 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104082] Wdangling-pointer: 2 * false positive ? Date: Tue, 18 Jan 2022 16:49:29 +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.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution blocked bug_status 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: Tue, 18 Jan 2022 16:49:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104082 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Blocks| |104077 Status|NEW |RESOLVED --- Comment #5 from Martin Sebor --- This form of the warning implements a commonly requested feature missing fr= om -Wreturn-local-addr (also included in -Wall): allowing the address of a loc= al variable to escape the scope of the function. Both warnings are issued for strictly valid code. See for example pr26671, pr49974, pr54301, pr82520, pr84544, pr90905 for related requests (the initial implementation is too simplistic to fully handle all these but eventually it should). A case ve= ry similar to the one in comment #0 is documented in the manual: In the following function the store of the address of the local variable = x in the escaped pointer *p also triggers the warning. void g (int **p) { int x =3D 7; *p =3D &x; // warning: storing the address of a local variable in *p } The duplication is (of course) a bug. Since the warning works as intended and documented (there's no false positi= ve) I'm going to resolve this report as invalid. If you want to request a sepa= rate level to control this aspect please open an enhancement request (I'm open to implementing it). If you want to remove this level from -Wall, please do t= he same (though I don't support that request). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104077 [Bug 104077] bogus/missing -Wdangling-pointer=