From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 05A163858413; Wed, 19 Jul 2023 15:59:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05A163858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689782354; bh=zRtkdhsUCR1mWfGeNOSi91UGgAIwPnfdCFeUDp0hhuQ=; h=From:To:Subject:Date:From; b=Xgow2doplT/bLvZeA4AzT3sx63oJ2svXMZR7oIh4bLJgFh1Q8fhxf0dIgrzoarwoL bH5gTN08064Fu59P5YqE9Xh3IHZUyly94aXuH0408GvVBeGRrofYc8M7je4yuUs6Ma /QyF2a7ayUJy3z6xCQZLb/s1mGiTVoVUzzfMAcd0= From: "arnd at linaro dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arnd at linaro 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=3D110743 Bug ID: 110743 Summary: Unexpected -ftrivial-auto-var-init=3Dpattern 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 struct= ure 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=3Dpattern -Wuninitial= ized 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) : In function 's25fs256t_post_bfpt_fixup_nor': :12:21: warning: 'op' is used uninitialized [-Wuninitialized] 12 | struct spi_mem_op op; | ^~ :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=3Dpattern. 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 on= e is marked fixed and I cannot reproduce it on gcc-12 or gcc-13.=