Bug 109911 - gcc 3.3.2-1 typedefs + aligned attribute does not align properly
gcc 3.3.2-1 typedefs + aligned attribute does not align properly
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-11-12 16:16 EST by Eric Sandeen
Modified: 2007-11-30 17:10 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-07 07:35:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
alignment test code (720 bytes, text/plain)
2003-11-12 16:17 EST, Eric Sandeen
no flags Details
test code showing alignment works for <4 bytes, not >4 bytes (3.97 KB, text/plain)
2004-05-24 14:59 EDT, David McKinley
no flags Details

  None (edit)
Description Eric Sandeen 2003-11-12 16:16:25 EST
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:

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.
Comment 1 Eric Sandeen 2003-11-12 16:17:11 EST
Created attachment 95931 [details]
alignment test code
Comment 2 Eric Sandeen 2003-11-12 16:19:31 EST
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.
Comment 3 Eric Sandeen 2003-11-12 16:25:46 EST
Update summary to make gcc version obvious in query results.
Comment 4 Eric Sandeen 2004-04-29 00:46:08 EDT
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?
Comment 5 David McKinley 2004-05-24 14:47:50 EDT
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.
Comment 6 David McKinley 2004-05-24 14:59:10 EDT
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
Comment 7 Eric Sandeen 2004-10-04 10:18:49 EDT
minor update, gcc version 3.4.1 20040831 (Red Hat 3.4.1-10)
from FC3 works fine with my original testcase.
Comment 8 Jakub Jelinek 2004-10-07 07:35:23 EDT
Yeah, it is works correctly in 3.4 and 4.0 and is a known problem
in GCC 3.3.
Comment 9 Eric Sandeen 2005-05-25 16:28:49 EDT
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?



Note You need to log in before you can comment on or make changes to this bug.