From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11646 invoked by alias); 18 Aug 2006 20:48:27 -0000 Received: (qmail 11538 invoked by uid 48); 18 Aug 2006 20:48:20 -0000 Date: Fri, 18 Aug 2006 20:48:00 -0000 Subject: [Bug c++/28777] New: Zerodetection (i != 0) compiled with -O2 don't work X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "hgsawicki at web dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-08/txt/msg01479.txt.bz2 List-Id: Compiling the following code with -O2 produces an buggy excecutable: (Using no optimization or -O1 produces an valid excecutable) ~~~ snip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include 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