This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/9932: alignment of 64-bit type in struct seems to be wrong
- From: hagen at equator dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 4 Mar 2003 03:58:06 -0000
- Subject: c/9932: alignment of 64-bit type in struct seems to be wrong
- Reply-to: hagen at equator dot com
>Number: 9932
>Category: c
>Synopsis: alignment of 64-bit type in struct seems to be wrong
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 04 04:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Hagen
>Release: gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)
>Organization:
>Environment:
redhat linux 7.2 running on Dell P4
>Description:
The following code generates different sizes for the two types test1 and tes2 (12 for test1 and 16 for test2):
#include <stdio.h>
typedef unsigned long long UInt64;
typedef struct {
int a;
UInt64 l;
} test1;
typedef struct {
int a;
UInt64 l __attribute__((aligned(8)));
} test2;
int main(void)
{
printf("%d %d\n", sizeof(test1), sizeof(test2));
printf("%d %d %d\n", __alignof(test1), __alignof(test2), __alignof(UInt64));
}
Since the alignment of UInt64 seems to be 8 bytes I would also expect type test1 to be of the size 16 (and have the alignment 8).
>How-To-Repeat:
compile the code: e.g. gcc test.c
run the resulting a.out and the result is:
12 16
4 8 8
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: