From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF36A385802B; Fri, 11 Feb 2022 17:40:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF36A385802B From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/102692] -Wanalyzer-null-dereference false alarm with (!p || q || !p->next) Date: Fri, 11 Feb 2022 17:40:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: dmalcolm at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED 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: 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: Fri, 11 Feb 2022 17:40:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102692 --- Comment #4 from David Malcolm --- I've been investigating the false positive from -Wanalyzer-use-of-uninitialized-value. It only happens when optimization is turned on, but happens within the FE, before gimplification. Specifically, c_parser_condition parses this condition: ((A OR-IF B) OR-IF C) and calls c_fully_fold on the condition. Within c_fully_fold, fold_truth_andor is called, which bails when optimizat= ion is off, but if any optimization is turned on converts the ((A OR-IF B) OR-IF C) into: ((A OR B) OR_IF C) and at gimplification time the inner OR becomes BIT_IOR_EXPR (in gimplify_expr), giving this for the inner condition: tmp =3D A | B if (tmp) thus effectively synthesizing a redundant access of B when optimization is turned on.=