public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ldeng at mail dot ustc.edu.cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96293] Extraneously noisy "taking address of packed member may result in an unaligned pointer value" Date: Wed, 06 Jul 2022 10:05:57 +0000 [thread overview] Message-ID: <bug-96293-4-GliEZv0R51@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96293-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96293 --- Comment #6 from Long Deng <ldeng at mail dot ustc.edu.cn> --- I met the same problem. I found that gcc issue this warning probably because `struct S` can located any address, which means that `s.d` may not alignment to 4. So as Richard said, you can use `__attribute__((packed, aligned(4))` to get rid of this warning, it still guaranteed that you struct is packed (i.e. `sizeof(S) == 8`), and struct itself will alignment to 4, so `s.d` will aligns correctly.
next prev parent reply other threads:[~2022-07-06 10:05 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-23 0:23 [Bug c/96293] New: " lavr at ncbi dot nlm.nih.gov 2020-07-23 6:02 ` [Bug c/96293] " rguenth at gcc dot gnu.org 2020-07-23 14:59 ` lavr at ncbi dot nlm.nih.gov 2020-07-23 15:01 ` lavr at ncbi dot nlm.nih.gov 2020-07-27 11:15 ` jakub at gcc dot gnu.org 2020-07-27 16:08 ` lavr at ncbi dot nlm.nih.gov 2022-07-06 10:05 ` ldeng at mail dot ustc.edu.cn [this message] 2022-07-06 14:05 ` lavr at ncbi dot nlm.nih.gov 2022-07-06 15:15 ` lavr at ncbi dot nlm.nih.gov 2022-07-07 8:23 ` ldeng at mail dot ustc.edu.cn 2022-07-07 13:13 ` lavr at ncbi dot nlm.nih.gov
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-96293-4-GliEZv0R51@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).