c++/10645: Incorrect 64bit double alignment in nested struct

jingye@ca.ibm.com jingye@ca.ibm.com
Tue May 6 19:28:00 GMT 2003


>Number:         10645
>Category:       c++
>Synopsis:       Incorrect 64bit double alignment in nested struct
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 06 19:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     jingye@ca.ibm.com
>Release:        gcc version 3.2
>Organization:
>Environment:
System Type:
Linux Version 2.4.19 SuSE SLES 8 (ppc) - Kernel 2.4.19-ul1-ppc64-SMP (36).
GNU assembler version 2.12.90.0.15 (powerpc-suse-linux) using BFD version 2.12.9
0.0.15 20020717 (SuSE)

Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-
prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/us
r/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-incl
ude-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared
--enable-__cxa_atexit powerpc-suse-linux
Thread model: posix
gcc version 3.2
>Description:
in the example below, the struct A has only double as its member and is 8-byte aligned in 64bit. struct B has struct A as it's member, however, is only 4-byte aligned. When we add aother member after double in struct A, struct B becomes 8-byte aligned.

/*test case t.c*/
struct A{
         double  a1;
         /*int     a2;*/
}sa;

struct B{
         char    b1;
         struct A     b2;
}sb;

int main()
{
   printf("alignof sa=%d\n",__alignof__(sa));
   printf("sizeof  sa=%d\n",sizeof(sa));
   printf("alignof sb=%d\n",__alignof__(sb));
   printf("sizeof  sb=%d\n",sizeof(sb));
}
>How-To-Repeat:
/opt/cross/bin/powerpc64-linux-g++ t.c

a.out
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list