From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B9A023858C36; Thu, 27 Jul 2023 12:41:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9A023858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690461701; bh=8VCysdJA8NnVBe+vJYPZg+2/p2SY22WoO4xekEqmfgI=; h=From:To:Subject:Date:From; b=lK0q+0sP9yw/1wS/DfzbLClsj1hMd8bbOT8qJSkJ6B07YGcpaczhD/sJfTDK0EGV3 BGTfHbg4fPGxvaxIwMvgX4ZGA46mLbMkMmrx+YsxCPnQi8mioCuutHQGK9fLQjrSxy ASHls/ftQ5oNXh7q7XD0BQjO5ZQvbTi8sNia7PMg= From: "vultkayn at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/110830] New: -Wanalyzer-use-of-uninitialized-value false negative due to use-after-free::supercedes_p. Date: Thu, 27 Jul 2023 12:41:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vultkayn at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110830 Bug ID: 110830 Summary: -Wanalyzer-use-of-uninitialized-value false negative due to use-after-free::supercedes_p. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: vultkayn at gcc dot gnu.org Target Milestone: --- state_machine::supercedes_p is called when two diagnostics are emitted for = the same statement, without regarding the path that led to this statement. See reproducer on trunk https://godbolt.org/z/GqebW5s5h=20 #include extern int ext(); int* foo() { int *p =3D 0; if (ext() > 5) { p =3D malloc (sizeof(int)); *p =3D 0; free (p); return p; } else return malloc(sizeof(int)); } void test() { int *y =3D foo(); // (*) int x =3D 4 + *y; free (y); } At statement (*) both -Wanalyzer-use-of-uninitialized-value and -Wanalyzer-use-after-free should be emitted as solving the latter won't imp= act the former, since they result from two independent branches. But use_after_free::supercedes_p hides the other. In the case of a false positive -Wanalyzer-use-after-free, or simply one ignored by the user, the adjacent -Wanalyzer-use-of-uninitialized-value wou= ld therefore never be emitted.=