Bug 109911 - gcc 3.3.2-1 typedefs + aligned attribute does not align properly
Summary: gcc 3.3.2-1 typedefs + aligned attribute does not align properly
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc   
(Show other bugs)
Version: 1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-11-12 21:16 UTC by Eric Sandeen
Modified: 2007-11-30 22:10 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-07 11:35:23 UTC
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 21:17 UTC, Eric Sandeen
no flags Details
test code showing alignment works for <4 bytes, not >4 bytes (3.97 KB, text/plain)
2004-05-24 18:59 UTC, David McKinley
no flags Details

Description Eric Sandeen 2003-11-12 21:16:25 UTC
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 21:17:11 UTC
Created attachment 95931 [details]
alignment test code

Comment 2 Eric Sandeen 2003-11-12 21:19:31 UTC
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 21:25:46 UTC
Update summary to make gcc version obvious in query results.

Comment 4 Eric Sandeen 2004-04-29 04:46:08 UTC
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 18:47:50 UTC
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 18:59:10 UTC
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 14:18:49 UTC
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 11:35:23 UTC
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 20:28:49 UTC
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.