From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 84CDE3858C53; Thu, 14 Apr 2022 11:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84CDE3858C53 From: "avarab at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/105273] New: -Wanalyzer-use-of-uninitialized-value warns on "missing" default for switch when callers can be statically determined Date: Thu, 14 Apr 2022 11:23:15 +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: avarab at gmail dot com 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 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: Thu, 14 Apr 2022 11:23:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105273 Bug ID: 105273 Summary: -Wanalyzer-use-of-uninitialized-value warns on "missing" default for switch when callers can be statically determined Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: avarab at gmail dot com Target Milestone: --- Created attachment 52807 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52807&action=3Dedit test case with an enum With GCC 12.0 built from c1ff207af66 (ppc: testsuite: skip pr60203 on no ldbl128, 2022-04-12) I get a warning on the attached test case: gcc -fanalyzer analyze.c analyze.c: In function =E2=80=98vreportf=E2=80=99: analyze.c:28:17: warning: use of uninitialized value =E2=80=98pfx=E2=80=99 = [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 28 | snprintf(buf, sizeof(buf), "%s", pfx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =E2=80=98vreportf=E2=80=99: events 1-6 | | 13 | const char *pfx; | | ^~~ | | | | | (1) region created on stack here | 14 |=20 | 15 | switch (kind) { | | ~~~~~~=20=20=20=20=20=20=20 | | | | | (2) following =E2=80=98default:=E2=80=99 branch... |...... | 25 | if (kind =3D=3D USAGE_BUG) | | ~=20=20=20=20=20=20=20=20=20 | | | | | (3) ...to here | | (4) following =E2=80=98false=E2=80=99 branch (when = =E2=80=98kind !=3D 1=E2=80=99)... |...... | 28 | snprintf(buf, sizeof(buf), "%s", pfx); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (5) ...to here | | (6) use of uninitialized value =E2=80=98pfx=E2= =80=99 here |=