From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E882E3858D35; Wed, 15 Feb 2023 16:36:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E882E3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676479004; bh=07ioiDh9RrwBMqCYJw5velurbDRWguZrzbD1SvNwV9M=; h=From:To:Subject:Date:From; b=NzKsSpu/FXQSwpj6cZFkAp4LGwj49aJFsBmLUPXjIy8M/Vo4VG1OxHK3LMAY3ux2l RIbtzeYdVaSF7JB9DrjXHB7S2PDRTpFsoZZJIrczeBk4pTmo9MqhUYZgNY5BneMYTy +aESenAcGjCpmw5de6lPqRuQb8jQyeSlh1i5WGCM= From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/108806] New: -Wanalyzer-null-dereference false positives due to not handling bitmasks Date: Wed, 15 Feb 2023 16:36:44 +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 blocked 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=3D108806 Bug ID: 108806 Summary: -Wanalyzer-null-dereference false positives due to not handling bitmasks 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 Blocks: 108562 Target Milestone: --- Created attachment 54470 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54470&action=3Dedit Reproducer Trunk: https://godbolt.org/z/77EbbPEW5 GCC 12.2: https://godbolt.org/z/o8bbMhPxW GCC 11.3: https://godbolt.org/z/o4dK3zn3b GCC 10.4: https://godbolt.org/z/GzEqzMMjW Lots of false positives of the form: : In function 'omap2_inth_read': :75:18: warning: dereference of NULL 'bank' [CWE-476] [-Wanalyzer-null-dereference] 75 | return bank->inputs; | ~~~~^~~~~~~~ 'omap2_inth_read': events 1-6 | | 40 | struct omap_intr_handler_bank_s* bank =3D NULL; | | ^~~~ | | | | | (1) 'bank' is NULL | 41 |=20 | 42 | if ((offset & 0xf80) =3D=3D 0x80) { | | ~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 | | | | | (2) following 'false' branch... |...... | 52 | switch (offset) { | | ~~~~~~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 | | | | | (3) ...to here | | (4) following 'case 128:' branch... |...... | 74 | case 0x80: | | ~~~~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 | | | | | (5) ...to here | 75 | return bank->inputs; | | ~~~~~~~~~~~~=20=20=20=20=20=20=20=20=20=20=20 | | | | | (6) dereference of NULL 'bank' | where if offset =3D=3D 128, then the: | 42 | if ((offset & 0xf80) =3D=3D 0x80) { | | ~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 | | | | | (2) following 'false' branch... |...... | 52 | switch (offset) { | | ~~~~~~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 | | | | | (3) ...to here edge is impossible, and "bank" will have been properly initialized. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108562 [Bug 108562] [meta-bug] tracker bug for issues with -Wanalyzer-null-derefer= ence=