From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8973E3853573; Thu, 12 Jan 2023 21:05:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8973E3853573 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673557516; bh=2bJEerN7Uya6ebJetvg6TB63tBLGPOYpkgrf4+itbzM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=htCEwN5rnMwFKzVuvIk6ei7wLJ+buX6ysEiQzaJve5AeQiIEGqg4wbkpgJFcD2Ivl b85I/UgNwoJIvBb1zzdexABd6BNU0pf0FeEGeNYhUctv+/ysNek0lvWtUktxpIJNCk XT3+WqQs50DfCMz7+zhueFf74Q3Ezx5Vv4EB294U= From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/105273] -Wanalyzer-use-of-uninitialized-value warns on "missing" default for switch when callers can be statically determined Date: Thu, 12 Jan 2023 21:05:16 +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: 12.0 X-Bugzilla-Keywords: diagnostic 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105273 --- Comment #6 from David Malcolm --- Another instance from Doom, this time where the enum is in a field lookup, rather than an input parameter: p_maputl.c: In function =E2=80=98P_BoxOnLineSide=E2=80=99: p_maputl.c:151:8: warning: use of uninitialized value =E2=80=98p1=E2=80=99 = [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 151 | if (p1 =3D=3D p2) | ^ =E2=80=98P_BoxOnLineSide=E2=80=99: events 1-5 | | 115 | int p1; | | ^~ | | | | | (1) region created on stack here | | (2) capacity: 4 bytes |...... | 118 | switch (ld->slopetype) | | ~~~~~~=20=20=20=20=20=20=20 | | | | | (3) following =E2=80=98default:=E2=80=99 branch... |...... | 151 | if (p1 =3D=3D p2) | | ~=20=20=20=20=20=20=20=20=20 | | | | | (4) ...to here | | (5) use of uninitialized value =E2=80=98p1=E2=80=99 here | where r_defs.h has: // // Move clipping aid for LineDefs. // typedef enum { ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE } slopetype_t; typedef struct line_s { [...snip...] // To aid move clipping. slopetype_t slopetype; [...snip...] } line_t; and all four enum values are covered by the switch statement.=