public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "edwintorok at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/35643]  New: gcc-4.2 -O1 -fstrict-aliasing misoptimization
Date: Wed, 19 Mar 2008 18:51:00 -0000	[thread overview]
Message-ID: <bug-35643-15165@http.gcc.gnu.org/bugzilla/> (raw)

When I compile the testcase with -O2, or with '-O1 -fstrict-aliasing' incorrect
code is generated. The testcase calls abort() in this case.

This is a regression in gcc-4.2 only: gcc-4.1 and gcc-4.3 do not show the bug.

$ gcc-4.2 -O1 test.i -o ok && ./ok
$ gcc-4.2 -O2 test.i -o fails && ./fails
Aborted
$ gcc-4.2 -O1 -fstrict-aliasing test.i -o fails2 && ./fails2
Aborted
$ gcc-4.2 -O3 test.i -o fails3 && ./fails3
Aborted

The testcase gives no warnings:
$ gcc-4.2 -Wall -W -O2 -Wstrict-aliasing test.i

The original code that  is miscompiled is ClamAV, but only if -O3 is used.
I created an initial reduced testcase using delta. 
Manually inlining some functions show this bug even at -O2 on the reduced
testcase.

I reproduced this on 2 different systems:

edwin@lightspeed2:~$ uname -a
Linux lightspeed2 2.6.25-rc4-00134-g84c6f60 #4 Sun Mar 9 19:40:34 EET 2008
x86_64 GNU/Linux

edwin@lightspeed2:~$ gcc-4.2 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--disable-libmudflap --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-2)

I also reproduced the bug with gcc 4.2.3 built with --enable-checking=yes:
edwin@lightspeed2:~$ gcc-4.2.3/inst/bin/gcc -O1 -fstrict-aliasing test.i -o
fails && ./fails
Aborted

edwin@lightspeed2:~$ gcc-4.2.3/inst/bin/gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../configure --enable-languages=c
--prefix=/home/edwin/gcc-4.2.3/obj/../inst --enable-checking=yes
--disable-multilib --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --disable-bootstrap
Thread model: posix
gcc version 4.2.3

The second system:
edwin@thunder:~$ uname -a
Linux thunder 2.6.25-rc5-00323-g9a9e0d6 #22 SMP PREEMPT Sun Mar 16 10:23:46 EET
2008 i686 GNU/Linux

edwin@thunder:~$ gcc-4.2 -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--disable-libmudflap --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-2)


-- 
           Summary: gcc-4.2 -O1 -fstrict-aliasing misoptimization
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: edwintorok at gmail dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643


             reply	other threads:[~2008-03-19 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-19 18:51 edwintorok at gmail dot com [this message]
2008-03-19 18:55 ` [Bug rtl-optimization/35643] " edwintorok at gmail dot com
2008-03-19 19:36 ` edwintorok at gmail dot com
2008-03-19 19:57 ` [Bug rtl-optimization/35643] [4.2 Regression] " rguenth at gcc dot gnu dot org
2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
2009-03-31 15:35 ` jsm28 at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-35643-15165@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).