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
* [Bug target/44060] miscompilation with -Os on x86
2010-05-10 14:23 [Bug target/44060] New: miscompilation with -Os on x86 bernhardloos at googlemail dot com
@ 2010-05-10 14:44 ` schwab at linux-m68k dot org
2010-05-10 14:58 ` bernhardloos at googlemail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: schwab at linux-m68k dot org @ 2010-05-10 14:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from schwab at linux-m68k dot org 2010-05-10 14:43 -------
Try -Wstrict-aliasing.
--
schwab at linux-m68k dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44060] miscompilation with -Os on x86
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bernhardloos at googlemail dot com @ 2010-05-10 14:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bernhardloos at googlemail dot com 2010-05-10 14:57 -------
(In reply to comment #1)
> Try -Wstrict-aliasing.
>
It does produce a warning about dreferencing a type-punned pointer.
I tried to compile the snipped with both -fstrict-aliasing and
-fno-strict-aliasing and it doesn't produce a difference in the code. Not on
the i486 gcc4.5 nor on the gcc4.4 in fedora.
Busybox uses this in some places and it did work in the past, so it would be
really nice, if this could get fixed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44060] miscompilation with -Os on x86
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
4 siblings, 0 replies; 6+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-05-10 16:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl dot tools at gmail dot com 2010-05-10 16:16 -------
Gcc 4.6 generates expected code.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44060] miscompilation with -Os on x86
2010-05-10 14:23 [Bug target/44060] New: miscompilation with -Os on x86 bernhardloos at googlemail dot com
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: pluto at agmk dot net @ 2010-05-10 16:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pluto at agmk dot net 2010-05-10 16:26 -------
(In reply to comment #3)
> Gcc 4.6 generates expected code.
>
PR43987 dupllication?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44060
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44060] miscompilation with -Os on x86
2010-05-10 14:23 [Bug target/44060] New: miscompilation with -Os on x86 bernhardloos at googlemail dot com
` (3 preceding siblings ...)
2010-05-10 16:26 ` pluto at agmk dot net
@ 2010-05-10 16:49 ` bernhardloos at googlemail dot com
4 siblings, 0 replies; 6+ messages in thread
From: bernhardloos at googlemail dot com @ 2010-05-10 16:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bernhardloos at googlemail dot com 2010-05-10 16:48 -------
It is a duplicate, my problem happens in exactly the same place.
Sorry I missed the other bug.
*** This bug has been marked as a duplicate of 43987 ***
--
bernhardloos at googlemail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
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).