From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2A2643858D33; Tue, 14 Mar 2023 19:30:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A2643858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678822231; bh=yKK3S+Y81XiYa6B3v03GJLs0QSFh88MoFuaO3BoZyUk=; h=From:To:Subject:Date:From; b=uUmtHcqj3goZ6OnU4esEuxylFiA+m15TJRnHPgrI3iu4P/dJx/axIYf9CN5v/amdb HFy2VLVb1IeQSRe7vdjaTUuq9+hUC+Gz4r/mLtDvL/C0KzHM5wuYri6ODZ8ykIVg8G BCD6u9LazClqsXBfkbxZytBSw3TweEVeEF7sBv/Q= From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109131] New: -Wanalyzer-deref-before-check false positive seen in git's builtin/show-ref.c Date: Tue, 14 Mar 2023 19:30:30 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dmalcolm 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 attachments.created 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=3D109131 Bug ID: 109131 Summary: -Wanalyzer-deref-before-check false positive seen in git's builtin/show-ref.c Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- Created attachment 54664 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54664&action=3Dedit Reduced reproducer Trunk erroneously emits: deref-before-check-git-show-ref.c: In function 'cmd_show_ref': deref-before-check-git-show-ref.c:39:8: warning: check of 'argv' for NULL a= fter already dereferencing it [-Wanalyzer-deref-before-check] 39 | if (!pattern) | ^ 'cmd_show_ref': events 1-8 | | 31 | if (exclude_arg) | | ^ | | | | | (1) following 'false' branch... |...... | 34 | pattern =3D argv; | | ~~~~~~~~~~~~~~ | | | | | (2) ...to here | 35 | if (!*pattern) | | ~ ~~~~~~~~ | | | | | | | (3) pointer 'argv' is dereferenced here | | (4) following 'false' branch... |...... | 38 | if (verify) { | | ~~~~~~~ | | || | | |(5) ...to here | | (6) following 'true' branch... | 39 | if (!pattern) | | ~~~~~~~~~ | | || | | |(7) ...to here | | (8) pointer 'argv' is checked for NULL here but it was already dereferenced at (3) | on the attached. https://godbolt.org/z/oW4hvqx7K=