public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15767] New: gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac
@ 2004-06-01 22:24 jingye at ca dot ibm dot com
  2004-06-01 22:33 ` [Bug target/15767] " pinskia at gcc dot gnu dot org
  2004-06-01 22:36 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: jingye at ca dot ibm dot com @ 2004-06-01 22:24 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/15767] gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac
  2004-06-01 22:24 [Bug c++/15767] New: gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac jingye at ca dot ibm dot com
@ 2004-06-01 22:33 ` pinskia at gcc dot gnu dot org
  2004-06-01 22:36 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-01 22:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-01 22:33 -------
Unless this is right for sysv4 PowerPC abi, then the problem is in the bug is in the sysv4 header:
/* An expression for the alignment of a structure field FIELD if the
   alignment computed in the usual way is COMPUTED.  */
#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)                                   \
        ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)     \
         ? 128 : COMPUTED)


The darwin result is correct in my mind in that it is packed, note really you should not be using packed 
with vectors anyways.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |target
     Ever Confirmed|                            |1
 GCC target triplet|                            |powerpc-*-linux-*, powerpc-
                   |                            |*-elf-*
           Keywords|                            |ABI
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-01 22:33:42
               date|                            |


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/15767] gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac
  2004-06-01 22:24 [Bug c++/15767] New: gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac jingye at ca dot ibm dot com
  2004-06-01 22:33 ` [Bug target/15767] " pinskia at gcc dot gnu dot org
@ 2004-06-01 22:36 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-01 22:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-01 22:35 -------
Also for record you should have filed with your vender first since they are the ones who provided you 
the binaries.

-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-06-01 22:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-01 22:24 [Bug c++/15767] New: gcc/sles9 type attribute aligned, packed on vector types behaves inconsistently with gcc/mac jingye at ca dot ibm dot com
2004-06-01 22:33 ` [Bug target/15767] " pinskia at gcc dot gnu dot org
2004-06-01 22:36 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).