http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46620
Summary: 32-bit structures containing bitfields are not copied correctly on -O2 , x86 backend Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: bnitule...@tremend.ro Created attachment 22499 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22499 Test case exhibiting the error The attached code contains a copy between two structures containing bitfields. The x86 code generated on -O2 fails to copy two fields in the structure. It is also very complex, trying to break the structure in sets of bitfields and copy them independently. I have attached an archive containing - file exhibiting the error (bitfield-error.c) - main file driving the example - generated assembly code (gcc -c -O2 bitfield-error.c -S) To run the code in the attachment gcc -c -O2 bitfield-error.c gcc -c -O0 bitfield-error-main.c gcc -o bitfield-error bitfield-error.o bitfield-error-main.o ./bitfield-error Result: 0, expected 1 Running at -O0 gives a different answer gcc -c -O0 bitfield-error.c gcc -o bitfield-error bitfield-error.o bitfield-error-main.o ./bitfield-error Result: 1, expected 1 The gcc used is the one from Ubuntu 10.04.1 LTS : $ gcc --version gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)