From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5478 invoked by alias); 20 Oct 2008 07:52:15 -0000 Received: (qmail 5462 invoked by uid 22791); 20 Oct 2008 07:52:14 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.salomon.at (HELO sauxb.salomon.at) (193.186.16.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 20 Oct 2008 07:51:31 +0000 Received: from servex01.wamas.com (servex01.salomon.at [172.28.2.2]) by sauxb.salomon.at (8.12.10/8.12.10) with ESMTP id m9K7okLZ012308 for ; Mon, 20 Oct 2008 09:51:10 +0200 (METDST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: structure packing. Date: Mon, 20 Oct 2008 07:52:00 -0000 Message-ID: <18597F2B47F1394A9B309945EC72411201BD92F3@servex01.wamas.com> From: "Duft Markus" To: X-Spam-Info: -1.008 () ALL_TRUSTED,AWL,BAYES_50,DNS_FROM_SECURITYSAGE X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00246.txt.bz2 >=20 > Hi! >=20 > I have a strange problem with some of my source code. I have something > similar as the small test case below, which I compile with multiple > different compilers (and compiler versions), including visual c++ 2003, > 2005 and 2008 and GCC 3.3 and 4.2. >=20 > It seems that gcc 4.2 makes some troubles ;) could please somebody take > a look at the things below, and tell me wether I'm just blind and dumb, > or there is a problem with gcc? Some more testing revealed that using the gcc_struct attribute additionally, makes it work.... is there any explanation for this? I thought gcc_struct would be the default? (btw. I _am_ on windows, but using interix, which I think should be pretty much unix, and nearly no windows...). Cheers, Markus >=20 > Thanks in advance, Cheers, Markus >=20 > mduft build $ cat zz.c > #include >=20 > typedef struct __attribute__((packed, aligned(2))) { > unsigned int a; > unsigned short b; > unsigned int c; > } teststruct; >=20 > int main(void) { > printf("uint: %d, ushort: %d, struct: %d (should be %d)\n", > sizeof(unsigned int), sizeof(unsigned short), > sizeof(teststruct), > (sizeof(unsigned int) * 2) + sizeof(unsigned short)); > } > mduft build $ gcc zz.c > mduft build $ ./a.out > uint: 4, ushort: 2, struct: 12 (should be 10) >=20 > mduft build $ gcc -v > Using built-in specs. > Target: i586-pc-interix6.0 > Configured with: /opt/gentoo.system/var/tmp/portage/sys-devel/gcc- > 4.2.4-r00.1/work/gcc-4.2.4/configure --prefix=3D/opt/gentoo.system/usr -- > bindir=3D/opt/gentoo.system/usr/i586-pc-interix6.0/gcc-bin/4.2.4 -- > includedir=3D/opt/gentoo.system/usr/lib/gcc/i586-pc- > interix6.0/4.2.4/include --datadir=3D/opt/gentoo.system/usr/share/gcc- > data/i586-pc-interix6.0/4.2.4 -- > mandir=3D/opt/gentoo.system/usr/share/gcc-data/i586-pc- > interix6.0/4.2.4/man --infodir=3D/opt/gentoo.system/usr/share/gcc- > data/i586-pc-interix6.0/4.2.4/info --with-gxx-include- > dir=3D/opt/gentoo.system/usr/lib/gcc/i586-pc- > interix6.0/4.2.4/include/g++-v4 --host=3Di586-pc-interix6.0 --build=3Di586- > pc-interix6.0 --disable-altivec --disable-nls --with-system-zlib -- > disable-checking --disable-werror --enable-secureplt --disable-multilib > --disable-libmudflap --disable-libssp --disable-libgcj --enable- > languages=3Dc,c++,treelang --enable-shared --enable-threads=3Dposix --with- > local-prefix=3D/opt/gentoo.system/usr > Thread model: posix > gcc version 4.2.4 (Gentoo 4.2.4-r00.1 p1.0) >=20 > mduft build $ /opt/gcc.3.3/bin/gcc zz.c > mduft build $ ./a.out > uint: 4, ushort: 2, struct: 10 (should be 10) > mduft build $