public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "arnd at linaro dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110743] New: Unexpected -ftrivial-auto-var-init=pattern behavior with partial bitfields Date: Wed, 19 Jul 2023 15:59:13 +0000 [thread overview] Message-ID: <bug-110743-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110743 Bug ID: 110743 Summary: Unexpected -ftrivial-auto-var-init=pattern behavior with partial bitfields Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: arnd at linaro dot org Target Milestone: --- A warning showed up in Linux kernel builds with code that has a data structure with sub-byte holes in it, making it appear as though the structure was uninitialized even though there is no user before the intialization: struct spi_mem_op { struct { int a : 1; }; struct { char b : 1; long c; }; }; void spi_nor_read_any_reg(struct spi_mem_op *); void s25fs256t_post_bfpt_fixup_nor(void) { struct spi_mem_op op; spi_nor_read_any_reg(&op); } $ x86_64-linux-gnu-gcc-12 -O2 -ftrivial-auto-var-init=pattern -Wuninitialized x86-64 gcc 12.3 (Editor #1) x86-64 gcc 12.3 - 905ms (5966B) ~392 lines filtered Output of x86-64 gcc 12.3 (Compiler #1) <source>: In function 's25fs256t_post_bfpt_fixup_nor': <source>:12:21: warning: 'op' is used uninitialized [-Wuninitialized] 12 | struct spi_mem_op op; | ^~ <source>:12:21: note: 'op' declared here 12 | struct spi_mem_op op; | ^~ See also https://godbolt.org/z/o96GfTaaT gcc-11 and earlier don't show this behavior because they do not support -ftrivial-auto-var-init=pattern. I notice that in the example above, the first 16 bytes of the structure are intialized to zero with an x86 SSE instruction since they do not contain any actual data bytes, just single bits. This seems to be the same underlying problem as in bug #104550, but that one is marked fixed and I cannot reproduce it on gcc-12 or gcc-13.
next reply other threads:[~2023-07-19 15:59 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-19 15:59 arnd at linaro dot org [this message] 2023-07-20 9:57 ` [Bug tree-optimization/110743] " 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-110743-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).