This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/44060] New: miscompilation with -Os on x86
- From: "bernhardloos at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 May 2010 14:23:45 -0000
- Subject: [Bug target/44060] New: miscompilation with -Os on x86
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Gcc 4.5 miscompiles the following code:
char buf[1024];
void add_input_file(int file)
{
(*((int **)&buf))[0] = file;
}
it results in this asm:
Disassembly of section .text:
00000000 <add_input_file>:
0: c3 ret
The file argument is completly ignored.
gcc4.4 does the right thing:
Disassembly of section .text:
00000000 <add_input_file>:
0: a1 00 00 00 00 mov 0x0,%eax
5: 8b 54 24 04 mov 0x4(%esp),%edx
9: 89 10 mov %edx,(%eax)
b: c3 ret
The command used to produce this output was i486-openwrt-linux-gcc -c asdf.c
-fomit-frame-pointer -Os -o asdf2.o
Openwrt adds a number of patches to gcc, they can be seen here:
https://dev.openwrt.org/browser/trunk/toolchain/gcc/patches/4.5.0
None of them should interfer with the codegeneration for x86.
The problem doesn't seem to happen with the mips target.
This is the output of gcc -v:
Using built-in specs.
COLLECT_GCC=../staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr/bin/i486-openwrt-linux-gcc
COLLECT_LTO_WRAPPER=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr/libexec/gcc/i486-openwrt-linux-uclibc/4.5.0/lto-wrapper
Target: i486-openwrt-linux-uclibc
Configured with:
/home/asdf/openwrt/trunk/build_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/gcc-4.5.0/configure
--prefix=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/usr
--build=i586-redhat-linux --host=i586-redhat-linux
--target=i486-openwrt-linux-uclibc --with-gnu-ld --enable-target-optspace
--disable-libgomp --disable-libmudflap --disable-multilib --disable-nls
--with-ppl --with-cloog --with-host-libstdcxx=-lstdc++
--with-gmp=/home/asdf/openwrt/trunk/staging_dir/host
--with-mpfr=/home/asdf/openwrt/trunk/staging_dir/host --disable-decimal-float
--disable-libssp --disable-__cxa_atexit --enable-languages=c,c++
--enable-shared --enable-threads
--with-slibdir=/home/asdf/openwrt/trunk/staging_dir/toolchain-i386_gcc-4.5.0_uClibc-0.9.30.3/lib
--enable-lto --disable-tls
Thread model: posix
gcc version 4.5.0 (GCC)
--
Summary: miscompilation with -Os on x86
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bernhardloos at googlemail dot com
GCC target triplet: i486-openwrt-linux-uclibc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060