This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/9932: alignment of 64-bit type in struct seems to be wrong


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]