public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22167] New: Strange optimization bug when using -Os
@ 2005-06-23 23:37 dahowell at directv dot com
  2005-06-23 23:48 ` [Bug c++/22167] " dahowell at directv dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: dahowell at directv dot com @ 2005-06-23 23:37 UTC (permalink / raw)
  To: gcc-bugs

The attached file osbugs.cpp will print a "BUG!!!!" message when compiled with 
the -Os switch with g++ 3.4.4 on powerpc.  This is due to the optimizer 
generating incorrect code, by apparently incorrectly determining that S::p is 
not being changed by the method S::init() before S::~S() is called.

I found this bug originally in the 3.3.5 version of the compiler, and it was 
causing a strange crash down in the basic_string code, but I've been able 
strip the code down to what I think is about the minimum needed to reproduce 
the optimization failure.  No pre-processor directives are in the attached 
source file.

The bug has been reproduced in mips-linux 3.3.5, and i386-linux 3.3.2 and 
3.3.5.  The bug does not appear in i386-linux 3.4.4.

Sample output, showing that this bug occurs across several different 
distributions of GCC:

powerpc, 3.4.4:

$ g++-3.4 --version | head -n1
g++-3.4 (GCC) 3.4.4 20050314 (prerelease) (Debian 3.4.3-13)
$ g++-3.4 -O2 osbugs.cpp -o osbugs
$ ./osbugs
p is 0x10011050 and p2 is 0x10011050 (should be non-zero and equal)
$ g++-3.4 -Os osbugs.cpp -o osbugs
$ ./osbugs
p is 0x0 and p2 is 0x0 (should be non-zero and equal)
BUG!!!! p is 0x10011050 and p2 is 0x0

i386, 3.3.5:

$ g++ --version | head -n1
g++ (GCC) 3.3.5 (Debian 1:3.3.5-13)
$ g++ -O2 osbugs.cpp -o osbugs
$ ./osbugs
p is 0x804a008 and p2 is 0x804a008 (should be non-zero and equal)
$ g++ -Os osbugs.cpp -o osbugs
$ ./osbugs
p is 0x0 and p2 is 0x0 (should be non-zero and equal)
BUG!!!! p is 0x804a008 and p2 is 0x0

i386, 3.3.2:

$ g++ --version | head -n1
g++ (GCC) 3.3.2 (Red Hat Linux 3.3.2-1)
$ g++ -O2 osbugs.cpp -o osbugs
$ ./osbugs
p is 0x8f0f008 and p2 is 0x8f0f008 (should be non-zero and equal)
$ g++ -Os osbugs.cpp -o osbugs
$ ./osbugs
p is 0x0 and p2 is 0x0 (should be non-zero and equal)
BUG!!!! p is 0x8497008 and p2 is 0x0

mips, 3.3.5:

$ mips-linux-g++ --version | head -n1
mips-linux-g++ (GCC) 3.3.5
$ mips-linux-g++ -O2 osbugs.cpp -o osbugs

[mipsbox]$ ./osbugs
p is 0x10000240 and p2 is 0x10000240 (should be non-zero and equal)

$ mips-linux-g++ -Os osbugs.cpp -o osbugs

[mipsbox]$ ./osbugs
p is 0x10000240 and p2 is 0x0 (should be non-zero and equal)
BUG!!!! p is 0x10000240 and p2 is 0x0

-- 
           Summary: Strange optimization bug when using -Os
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dahowell at directv dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-linux
  GCC host triplet: powerpc-linux
GCC target triplet: powerpc-linux


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


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

end of thread, other threads:[~2005-07-21  6:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
2005-06-23 23:48 ` [Bug c++/22167] " dahowell at directv dot com
2005-06-23 23:49 ` dahowell at directv dot com
2005-06-24 14:14 ` [Bug rtl-optimization/22167] " pinskia at gcc dot gnu dot org
2005-06-29 14:41 ` [Bug rtl-optimization/22167] [3.4/4.0?/4.1? regression] " reichelt at gcc dot gnu dot org
2005-06-29 15:14 ` [Bug rtl-optimization/22167] [3.4 " pinskia at gcc dot gnu dot org
2005-07-14 13:49 ` rsandifo at gcc dot gnu dot org
2005-07-14 18:05 ` [Bug rtl-optimization/22167] [3.4, 4.1 " rsandifo at gcc dot gnu dot org
2005-07-14 19:27 ` [Bug rtl-optimization/22167] [3.4/4.0/4.1 " pinskia at gcc dot gnu dot org
2005-07-21  6:53 ` cvs-commit at gcc dot gnu dot org
2005-07-21  6:56 ` cvs-commit at gcc dot gnu dot org
2005-07-21  6:58 ` cvs-commit at gcc dot gnu dot org
2005-07-21  7:10 ` rsandifo at gcc dot gnu dot org

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