public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "petro.karashchenko at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/88085] User alignments on var decls not respected if smaller than type alignment Date: Thu, 02 Sep 2021 10:45:43 +0000 [thread overview] Message-ID: <bug-88085-4-iZcBD5urdI@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-88085-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88085 --- Comment #18 from Petro Karashchenko <petro.karashchenko at gmail dot com> --- Yes. So I just checked GCC man and see that The aligned attribute can only increase the alignment; but you can decrease it by specifying packed as well. See below. Note that the effectiveness of aligned attributes may be limited by inherent limitations in your linker. On many systems, the linker is only able to arrange for variables to be aligned up to a certain maximum alignment. (For some linkers, the maximum supported alignment may be very very small.) If your linker is only able to align variables up to a maximum of 8 byte alignment, then specifying aligned(16) in an __attribute__ will still only provide you with 8 byte alignment. See your linker documentation for further information. So typedef int tolerant_int __attribute__((aligned(1))); extern tolerant_int possibly_misaligned_data; "possibly_misaligned_data" will still be 4 bytes aligned. The real problem is that "packed" can be applied only to struct or union type definition, I can't just do typedef int tolerant_int __attribute__((packed)); extern tolerant_int possibly_misaligned_data; So it will simply not work and I need to wrap a variable into a struct or union.
next prev parent reply other threads:[~2021-09-02 10:45 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-88085-4@http.gcc.gnu.org/bugzilla/> 2021-09-02 0:49 ` pinskia at gcc dot gnu.org 2021-09-02 0:53 ` pinskia at gcc dot gnu.org 2021-09-02 3:30 ` pinskia at gcc dot gnu.org 2021-09-02 3:31 ` pinskia at gcc dot gnu.org 2021-09-02 3:33 ` pinskia at gcc dot gnu.org 2021-09-02 3:37 ` pinskia at gcc dot gnu.org 2021-09-02 3:44 ` pinskia at gcc dot gnu.org 2021-09-02 7:12 ` rguenth at gcc dot gnu.org 2021-09-02 9:21 ` petro.karashchenko at gmail dot com 2021-09-02 9:38 ` rguenth at gcc dot gnu.org 2021-09-02 9:59 ` petro.karashchenko at gmail dot com 2021-09-02 10:06 ` petro.karashchenko at gmail dot com 2021-09-02 10:24 ` rguenther at suse dot de 2021-09-02 10:38 ` petro.karashchenko at gmail dot com 2021-09-02 10:41 ` rguenther at suse dot de 2021-09-02 10:45 ` petro.karashchenko at gmail dot com [this message] 2021-09-02 10:50 ` petro.karashchenko at gmail dot com 2021-09-02 11:04 ` petro.karashchenko at gmail dot com 2021-09-02 11:59 ` rguenther at suse dot de
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-88085-4-iZcBD5urdI@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).