public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16786] New: alignment incorrect on a structure field, on win32
@ 2004-07-27 18:45 antoine_labour at playstation dot sony dot com
2004-07-27 18:46 ` [Bug c/16786] " antoine_labour at playstation dot sony dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: antoine_labour at playstation dot sony dot com @ 2004-07-27 18:45 UTC (permalink / raw)
To: gcc-bugs
There seems to be a problem with alignment on win32 targets (cygwin, mingw).
I use gcc 3.3.1, either the one in cygwin :
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld
--with-gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
--libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man
--infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pascal,java,objc
--enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls
--without-included-gettext --enable-interpreter --enable-sjlj-exceptions
--disable-version-specific-runtime-libs --enable-shared --disable-win32-registry
--enable-java-gc=boehm --disable-hash-synchronization --verbose
--target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
or the linux->win32 cross compiler in debian:
$ i586-mingw32msvc-gcc -v
Reading specs from /usr/lib/gcc-lib/i586-mingw32msvc/3.3.1/specs
Configured with:
/home/ron/devel/debian/mingw32/mingw32-3.3.1.20030804.1/build_dir/src/gcc-3.3.1-20030804-1/configure
-v --prefix=/usr --target=i586-mingw32msvc --enable-languages=c,c++
--enable-threads --disable-multilib --enable-version-specific-runtime-libs
Thread model: win32
gcc version 3.3.1 (mingw special 20030804-1)
The compiler seems to ignore alignment requirement on struct fields which are
declared with a type having some alignment requirement set with the align attribute:
typedef struct
{
int a;
} __attribute__((aligned (16))) A;
typedef struct
{
int b;
A a;
} B;
B.a seems to be aligned on a 8-byte boundary, whereas it should be on a 16-byte
boundary. The size seems correct though.
See attached file for test case.
To compile, I used:
$ gcc prog.i -o prog.exe -Wall
It gives no warning.
Its output is the following:
$ ./prog.exe
offsetof(B,a)=0x8
sizeof(A)=0x10
sizeof(B)=0x18
alignof(A)=10
alignof(B)=8
I can see the correct behaviour with linux i386 gcc, both 3.3.4 and 3.2.3
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.4/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.4 (Debian)
$ gcc-3.2 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs
Configured with: ../src/configure -v --enable-languages=c,c++,f77,objc,ada
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.3 (Debian)
$ gcc prog.i -o prog -Wall
$./prog
offsetof(B,a)=0x10
sizeof(A)=0x10
sizeof(B)=0x20
alignof(A)=10
alignof(B)=10
--
Summary: alignment incorrect on a structure field, on win32
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: antoine_labour at playstation dot sony dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16786
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/16786] alignment incorrect on a structure field, on win32
2004-07-27 18:45 [Bug c/16786] New: alignment incorrect on a structure field, on win32 antoine_labour at playstation dot sony dot com
@ 2004-07-27 18:46 ` antoine_labour at playstation dot sony dot com
2004-07-27 21:07 ` dannysmith at users dot sourceforge dot net
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: antoine_labour at playstation dot sony dot com @ 2004-07-27 18:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From antoine_labour at playstation dot sony dot com 2004-07-27 18:46 -------
Created an attachment (id=6841)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6841&action=view)
test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16786
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/16786] alignment incorrect on a structure field, on win32
2004-07-27 18:45 [Bug c/16786] New: alignment incorrect on a structure field, on win32 antoine_labour at playstation dot sony dot com
2004-07-27 18:46 ` [Bug c/16786] " antoine_labour at playstation dot sony dot com
@ 2004-07-27 21:07 ` dannysmith at users dot sourceforge dot net
2004-07-27 21:21 ` bangerth at dealii dot org
2004-07-27 21:29 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-07-27 21:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dannysmith at users dot sourceforge dot net 2004-07-27 21:07 -------
The testcase also fails on gcc-3.3.3 on mingw.
It gives correct results on 3.4.1 and trunk (20040726) on mingw
offsetof(B,a)=0x10
sizeof(A)=0x10
sizeof(B)=0x20
alignof(A)=10
alignof(B)=10
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16786
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/16786] alignment incorrect on a structure field, on win32
2004-07-27 18:45 [Bug c/16786] New: alignment incorrect on a structure field, on win32 antoine_labour at playstation dot sony dot com
2004-07-27 18:46 ` [Bug c/16786] " antoine_labour at playstation dot sony dot com
2004-07-27 21:07 ` dannysmith at users dot sourceforge dot net
@ 2004-07-27 21:21 ` bangerth at dealii dot org
2004-07-27 21:29 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-07-27 21:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-07-27 21:21 -------
Is this a regression? Since, from your messages it appears
as if it has been fixed in 3.4, and that it won't be fixed in 3.3.x any more
unless there's a really easy fix.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16786
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/16786] alignment incorrect on a structure field, on win32
2004-07-27 18:45 [Bug c/16786] New: alignment incorrect on a structure field, on win32 antoine_labour at playstation dot sony dot com
` (2 preceding siblings ...)
2004-07-27 21:21 ` bangerth at dealii dot org
@ 2004-07-27 21:29 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27 21:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-27 21:29 -------
*** This bug has been marked as a duplicate of 14191 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16786
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-07-27 21:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-27 18:45 [Bug c/16786] New: alignment incorrect on a structure field, on win32 antoine_labour at playstation dot sony dot com
2004-07-27 18:46 ` [Bug c/16786] " antoine_labour at playstation dot sony dot com
2004-07-27 21:07 ` dannysmith at users dot sourceforge dot net
2004-07-27 21:21 ` bangerth at dealii dot org
2004-07-27 21:29 ` 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).