Description of problem: When using the aligned attribute on a typedef'd variable, this attribute seems to get lost, and structure members are not properly aligned. Version-Release number of selected component (if applicable): gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) How reproducible: Always Steps to Reproduce: 1. Compile the attached code 2. Observe incorrect output - 2nd structure member is not 8-byte aligned Actual Results: sizeof my_struct 12 offset of foo in my_struct is 0 offset of bar in my_struct is 4 Expected Results: sizeof my_struct 16 offset of foo in my_struct is 0 offset of bar in my_struct is 8 Additional info: This same bug is present in gcc-2.96-113, was gone in several gcc 3.x versions (the gcc32 package in FC1 is fine), but reappeared in 3.3.2.
Created attachment 95931 [details] alignment test code
Was going to add to "related bugs" but I'm not sure if it's a dependency, or a blocker of, bug 90567 ... noted here, though.
Update summary to make gcc version obvious in query results.
gcc 3.3.3-7 in fc2 test3 also fails; 3.2.3-6 (gcc32) seems to work. this bug seems to bounce back and forth, any ideas?
I've seen the same, or at least a very similar problem with gcc version 3.3.3 (Debian 20040401); the problem does not exist in gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5). What I've noted is that the typedef'ed attribute information is not completely lost; I'm attaching a test case that shows that it has an effect if the alignment for a long long is set to 1 or 2 bytes, but has no effect when setting it to larger than 4 bytes. As with the other test case, when attribute is assigned directly to the structure field, it works for all alignments.
Created attachment 100515 [details] test code showing alignment works for <4 bytes, not >4 bytes Source code for a test program with runs after compiling it on a system with gcc 3.3.3 and gcc 3.2.2. Results are as expected on 3.2.2, appear broken on 3.3.3.
minor update, gcc version 3.4.1 20040831 (Red Hat 3.4.1-10) from FC3 works fine with my original testcase.
Yeah, it is works correctly in 3.4 and 4.0 and is a known problem in GCC 3.3.
Jakub, blast from the past here... :) I need to use a system with 3.3.3 installed, is this a known/fixed bug in GCC so that I could backport the fix? Thanks, -Eric