public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dennisl@tri-linktech.com To: gcc-gnats@gcc.gnu.org Cc: dennislo@geocities.com Subject: c/3580: __attribute__((aligned(2))) on a char array typedef affects unrelated char arrays. Date: Thu, 05 Jul 2001 16:26:00 -0000 [thread overview] Message-ID: <20010705232212.27505.qmail@sourceware.cygnus.com> (raw) >Number: 3580 >Category: c >Synopsis: __attribute__((aligned(2))) on a char array typedef affects unrelated char arrays. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Jul 05 16:26:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Dennis Lo >Release: gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) >Organization: >Environment: Linux dlx.tri-linktech.com 2.2.14-5.0 #1 Tue Mar 7 20:53:41 EST 2000 i686 unknown >Description: Using __attribute__((aligned(2))) on a char array typedef will unintentionally apply this alignment on subsequently defined char arrays of the exactly the same size. In the following code, the char array typedef DUMMY is never used. When typedef DUMMY is commented out, this program prints "offset=1". When typedef DUMMY is uncommented, this program prints "offset=2". >How-To-Repeat: Compile the following code under RedHat 6.1 using "gcc bug.c" and then run a.out. It prints "offset=1". Uncomment the DUMMY typedef, recompile, and rerun. It prints "offset=2". >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="bug.c" Content-Disposition: inline; filename="bug.c" // // Synopsis: // __attribute__((aligned(2))) on a char array typedef affects // unrelated char arrays. // // Description: // Using __attribute__((aligned(2))) on a char array typedef will // unintentionally apply this alignment on subsequently defined char // arrays of the exactly the same size. // // In the following code, the char array typedef DUMMY is never used. // When typedef DUMMY is commented out, this program prints "offset=1". // When typedef DUMMY is uncommented, this program prints "offset=2". // // Release: // gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) // RedHat Linux 6.1. // // How to Repeat: // Compile the following code and run it. It prints "offset=1". // Uncomment the DUMMY typedef, compile, and run again. It prints // "offset=2". // //typedef char DUMMY[3] __attribute__((aligned(2))); typedef struct { char a1; char a2 [3]; } A; A aaa; int main (int argc, char* argv[]) { unsigned long offset = ((unsigned long) aaa.a2) - ((unsigned long) &aaa); printf ("offset=%lu\n", offset); }
next reply other threads:[~2001-07-05 16:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-05 16:26 dennisl [this message] 2001-10-05 11:42 jsm28
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=20010705232212.27505.qmail@sourceware.cygnus.com \ --to=dennisl@tri-linktech.com \ --cc=dennislo@geocities.com \ --cc=gcc-gnats@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).