public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28777]  New: Zerodetection (i != 0) compiled with -O2 don't work
@ 2006-08-18 20:48 hgsawicki at web dot de
  2006-08-18 21:09 ` [Bug tree-optimization/28777] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hgsawicki at web dot de @ 2006-08-18 20:48 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2251 bytes --]

Compiling the following code with -O2 produces an buggy excecutable:
(Using no optimization or -O1 produces an valid excecutable)
~~~ snip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <iostream>

int main( void )
{
    for ( int i = 1; i != 0; i = i + 1 )
    {
        if ( ! (i % 100000000) )
        {
            std::cout << i << std::endl;

            if ( i == 0 )
            {
                std::cout << i << std::endl;
            }
        }
    }

    return 0;
}
~~~ snip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Commands to build and execute:

~/c++work/multtest> g++ -O2 -o multtest main.cpp
~/c++work/multtest> ./multtest
100000000
200000000
:
-200000000
-100000000
0
100000000
200000000
:                       // and continues

== Environment =======================================

~/c++work/multtest> gcc --version
gcc (GCC) 4.1.1 (Gentoo 4.1.1)
Copyright (C) 2006 Free Software Foundation, Inc.
Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es
gibt KEINE Garantie; auch nicht für MARKTGÄNGIGKEIT oder FÜR SPEZIELLE ZWECKE.

~/c++work/multtest> uname --all
Linux atlantis 2.6.17-gentoo-r5 #5 SMP PREEMPT Mon Aug 14 19:48:18 CEST 2006
i686 AMD Athlon(tm) XP 2500+ AuthenticAMD GNU/Linux

~/c++work/multtest> cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 10
model name      : AMD Athlon(tm) XP 2500+
stepping        : 0
cpu MHz         : 1837.783
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow up ts
bogomips        : 3679.34


-- 
           Summary: Zerodetection (i != 0) compiled with -O2 don't work
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hgsawicki at web dot de


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


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

end of thread, other threads:[~2006-08-21  5:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-18 20:48 [Bug c++/28777] New: Zerodetection (i != 0) compiled with -O2 don't work hgsawicki at web dot de
2006-08-18 21:09 ` [Bug tree-optimization/28777] " pinskia at gcc dot gnu dot org
2006-08-19 15:26 ` rguenth at gcc dot gnu dot org
2006-08-21  5:03 ` pinskia 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).