From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 28A973858292; Tue, 5 Jul 2022 18:04:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28A973858292 From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/106204] New: False positive from -Wanalyzer-use-of-uninitialized-value with -ftrivial-auto-var-init=zero Date: Tue, 05 Jul 2022 18:04:08 +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: 12.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 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 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: Tue, 05 Jul 2022 18:04:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106204 Bug ID: 106204 Summary: False positive from -Wanalyzer-use-of-uninitialized-value with -ftrivial-auto-var-init=3Dzero Product: gcc Version: 12.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: --- I'm seeing a lot of false positives from -Wanalyzer-use-of-uninitialized-va= lue when building the upstream Linux kernel. Seems to be a bad interaction with -ftrivial-auto-var-init=3Dzero; minimal reproducer: $ cat ../../src/hooks.c int foo(unsigned *len); int test() { unsigned len; int rc; rc =3D foo(&len); if (!rc) rc =3D len; return rc; } $ ./xgcc -B. ../../src/hooks.c -ftrivial-auto-var-init=3Dzero -fanalyzer -S= =20 ../../src/hooks.c: In function =E2=80=98test=E2=80=99: ../../src/hooks.c:4:11: warning: use of uninitialized value =E2=80=98=E2=80=99 [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 4 | unsigned len; | ^~~ =E2=80=98test=E2=80=99: event 1 | | 4 | unsigned len; | | ^~~ | | | | | (1) use of uninitialized value =E2=80=98=E2= =80=99 here | where the uninit is being reported on the assignment to "len =3D _1;" here: _1 =3D .DEFERRED_INIT (4, 2, &"len"[0]); len =3D _1;=