public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/44060]  New: miscompilation with -Os on x86
@ 2010-05-10 14:23 bernhardloos at googlemail dot com
  2010-05-10 14:44 ` [Bug target/44060] " schwab at linux-m68k dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bernhardloos at googlemail dot com @ 2010-05-10 14:23 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2010-05-10 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-10 14:23 [Bug target/44060] New: miscompilation with -Os on x86 bernhardloos at googlemail dot com
2010-05-10 14:44 ` [Bug target/44060] " schwab at linux-m68k dot org
2010-05-10 14:58 ` bernhardloos at googlemail dot com
2010-05-10 16:16 ` hjl dot tools at gmail dot com
2010-05-10 16:26 ` pluto at agmk dot net
2010-05-10 16:49 ` bernhardloos at googlemail dot com

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).