[Bug c/12435] New: Array Element Alignment
mnmoran at bellsouth dot net
gcc-bugzilla@gcc.gnu.org
Sun Sep 28 17:40:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12435
Summary: Array Element Alignment
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mnmoran at bellsouth dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
The gcc mailing list thread that starts with this message
explores the issue.
http://gcc.gnu.org/ml/gcc/2003-09/msg01031.html
#include <stdio.h>
typedef unsigned char achar __attribute__ ((__aligned__(32)));
achar a[2];
int main(int argc,char* argv[]){
printf("__alignof__(achar):%u\n",__alignof__(achar));
printf("__alignof__(a[1]):%u\n",__alignof__(a[1]));
printf("&a: %8.8lX\n",(unsigned long)&a);
printf("sizeof(a):%u\n",sizeof(a));
printf("sizeof(a[0]):%u\n",sizeof(a[0]));
printf("&a[0]: %8.8lX\n",(unsigned long)&a[0]);
printf("&a[1]: %8.8lX\n",(unsigned long)&a[1]);
return 0;
}
% gcc -o main main.c ; main
__alignof__(achar):32
__alignof__(a[1]):1
&a: 08049740
sizeof(a):32
sizeof(a[0]):1
&a[0]: 08049740
&a[1]: 08049741 <<<<<<<<<<<< I expected this to be 08049760
% gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
I expected the second element of the array to be aligned
as well as the first, since the alignment of the type is 32.
More information about the Gcc-bugs
mailing list