public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jwzeng at nuaa dot edu.cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113232] New: wrong code at -fpack-struct on x86_64-pc-linux-gnu Date: Thu, 04 Jan 2024 12:01:24 +0000 [thread overview] Message-ID: <bug-113232-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113232 Bug ID: 113232 Summary: wrong code at -fpack-struct on x86_64-pc-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jwzeng at nuaa dot edu.cn Target Milestone: --- I compiled the following code with gcc at -fpack-struct, and it produces the wrong code. The correct output result should be 0, but 2048 was output under -fpack-struct. This bug seems to be a long-standing bug that exists on almost all gcc versions. Compiler explorer: https://godbolt.org/z/v4sq988P9 ```c $ cat test.c int printf(const char *, ...); struct a { char b; short c; }; union { short b; struct a d; } e; int main() { e.b = 0; for (e.d.c = 0; e.d.c < 8; e.d.c++) ; printf("%d\n", e.b); } $ $ gcc-tk test.c -O0; ./test.c 0 $ gcc-tk test.c -fpack-struct; ./test.c 2048 $ ccomp test.c -O0; ./a.out 0 $ $ gcc-tk --version gcc (GCC) 13.1.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ $ ccomp --version The CompCert C verified compiler, version 3.12 ```
next reply other threads:[~2024-01-04 12:01 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-04 12:01 jwzeng at nuaa dot edu.cn [this message] 2024-01-04 15:01 ` [Bug c/113232] " pinskia 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-113232-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).