From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC5143858D1E; Sat, 15 Oct 2022 22:15:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC5143858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665872156; bh=qNThwSHrkk7IVEx0gKFVH6pg0oZluO72SgGvQQsWyaQ=; h=From:To:Subject:Date:From; b=CzUwpI1aIEd3sxJitw4qBMXHD8YFrxLBJjG7gzqIwa+ANddL4qGHoMorHa+JfgCvM APdWYob4ZOZa0a+Os2OmQL+QUpw13Rv0BEqTIpQULSgU8JQAUstDhC0YIhyFNOL4He fdNi2P8EIE+7EW+YtSHyJN98nQHbHmDiLfjT4z0k= From: "keegan at undefinedbehaviour dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107274] New: Incorrect -Wuninitialized on indexed initialization Date: Sat, 15 Oct 2022 22:15:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: keegan at undefinedbehaviour dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107274 Bug ID: 107274 Summary: Incorrect -Wuninitialized on indexed initialization Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: keegan at undefinedbehaviour dot org Target Milestone: --- Given: void example(unsigned long val) { unsigned char b[4]; b[0] =3D val; b[1] =3D val >> 8; b[2] =3D val >> 16; b[3] =3D val >> 24; val =3D *(unsigned long *)b; } GCC 12.2 issues the following (incorrect) diagnostic: issue.c: In function 'example': issue.c:11:13: warning: 'b' is used uninitialized [-Wuninitialized] 11 | val =3D *(unsigned long *)b; | ~~~~^~~~~~~~~~~~~~~~~~~~~ issue.c:4:23: note: 'b' declared here 4 | unsigned char b[4]; | ^ Instead this code is correct in that it initializes all fields of "b". It appears the cast indirection is what is causing the issue, because I cannot= get the diagnostic to be issued for other uses.=