From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A648E3858D37; Wed, 2 Feb 2022 19:12:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A648E3858D37 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/104076] bogus -Wdangling-pointer on a conditional Date: Wed, 02 Feb 2022 19:12:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end 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: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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: Wed, 02 Feb 2022 19:12:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104076 --- Comment #5 from Martin Sebor --- Unlike the false positive -Wuse-after-free in pr104232, the instance of -Wdangling-pointer in this case (a PHI argument) is intentional so that we diagnose problems like those in the request for it (pr63272), or in this mo= re involved test case: void warn_cond_if (int i, int n) { int *p; if (i) { int a[] =3D { 1, 2 }; // { dg-message "'a' declared" "note" } sink (a); p =3D a; } else p =3D (int*)malloc (n); sink (p); // { dg-warning "dangling pointer 'p' to 'a' = may be used" } } I could add another level to -Wdangling-pointer to separately control uses = in equality expressions, for consistency with -Wuse-after-free.=