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]

[Bug c++/15767] New: gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac


gcc3.3/sles9 is inconsistent with gcc3.3/macos when packed type attribute is 
applied
to an aggregation that has vector type(s) as its member(s) -- see the test case 
below.

gcc/macos respects the packed attribute, packs all the members of struct A, 
however,
gcc/sles9 ignores the attribute packed, gives the alignment of 16 for the 
struct.

------------------
/*test case t.c*/
------------------

#include<stdio.h>
#include<stddef.h>
#if !defined(__APPLE__)
#include<altivec.h>
#endif

struct __attribute__((packed)) A {
   char     a1;
   vector signed int a2;
}sa;

int main()
{
    printf("sizeof sa is %d\n", sizeof(sa));
    printf("alignof sa is %d\n", __alignof__(sa));
    printf("offsetofof sa is %d\n", offsetof(struct A, a2));
}

results in gcc/mac
--------------------
sizeof sa is 17
alignof sa is 1
offsetofof sa is 1

results in gcc/sles9
----------------------
sizeof sa is 32
alignof sa is 16
offsetofof sa is 16

There is another test case which involves vector and type attribute aligned. 
gcc/sles9
behavior is also inconsistent with gcc/macos:

/*test case a.c */

#include<stdio.h>
#include<stddef.h>
#if !defined(__APPLE__)
#include<altivec.h>
#endif

typedef __attribute__((aligned(2))) vector unsigned char   myChar;

struct A {
    char      c;
    myChar    a;
    char      b;
}sa;

int main()
{
    printf("sizeof sa is %d\n", sizeof(sa));
    printf("alignof sa is %d\n", __alignof__(sa));
    printf("offsetof a is %d\n",offsetof(struct A, a));
    printf("offsetof b is %d\n",offsetof(struct A, b));
}

results in gcc/macos
--------------------
sizeof sa is 20
alignof sa is 2
offsetof a is 2
offsetof b is 18

results in gcc/sles9
---------------------
sizeof sa is 48
alignof sa is 16
offsetof a is 16
offsetof b is 32

---------
Release:
---------
gcc version 3.3

-----------------------
Environment: 
-----------------------
SLES9 INFO
-----------
system type: (uname -a)
Linux c2blade2 2.6.5-20040518-pseries64 #1 SMP Tue May 18 14:15:24 UTC 2004 
ppc64 ppc64 ppc64 GNU/Linux

gcc version (gcc -v)
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)

Reading specs from /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-
prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --enable-
languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib --enable-
libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-
system-zlib --enable-shared --enable-__cxa_atexit --host=powerpc-suse-linux --
build=powerpc-suse-linux --target=powerpc-suse-linux --enable-targets=powerpc64-
suse-linux --enable-biarch
Thread model: posix
gcc version 3.3.3 (SuSE Linux)

MAC INFO
----------
system type:
Darwin mira.torolab.ibm.com 7.3.0 Darwin Kernel Version 7.3.0: Fri Mar  5 
14:22:55 PST 2004; root:xnu/xnu-517.3.15.obj~4/RELEASE_PPC  Power Macintosh 
powerpc

gcc version
Darwin mira.torolab.ibm.com 7.3.0 Darwin Kernel Version 7.3.0: Fri Mar  5 
14:22:55 PST 2004; root:xnu/xnu-517.3.15.obj~4/RELEASE_PPC  Power Macintosh 
powerpc
@mira:/home/jingye/defects/lnxv7/287200 => gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1492)

----------------
How-To-Repeat:
----------------
gcc -maltivec t.c (on sles9) or
gcc -faltivec t.c (on macos)

a.out

-- 
           Summary: gcc/sles9 type attribute aligned, packed on vector types
                    behaves inconsistently with gcc/mac
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jingye at ca dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,nasgaard at ca dot ibm
                    dot com,skasapin at ca dot ibm dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15767


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