public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "keegan at undefinedbehaviour dot org" <gcc-bugzilla@gcc.gnu.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 [thread overview] Message-ID: <bug-107274-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107274 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] = val; b[1] = val >> 8; b[2] = val >> 16; b[3] = val >> 24; val = *(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 = *(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.
next reply other threads:[~2022-10-15 22:15 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-15 22:15 keegan at undefinedbehaviour dot org [this message] 2022-10-15 22:19 ` [Bug tree-optimization/107274] " pinskia at gcc dot gnu.org 2022-10-17 8:00 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107274-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).