From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13979 invoked by alias); 1 Oct 2007 17:02:48 -0000 Received: (qmail 13777 invoked by uid 48); 1 Oct 2007 17:02:33 -0000 Date: Mon, 01 Oct 2007 17:02:00 -0000 Subject: [Bug c++/33611] New: Optimizations generate incorrect code X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "macracan at yahoo dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg00050.txt.bz2 The following snipped when compiled with -O0 generates a program that quickly finishes (correct behavior). But when compiled with any optimizations (-O1, -O2 or -O3) generates a program that never finishes. Variations on the code, (such as the comment line) geneate valid program with either level of optimization. Checked in 4.1.1 too (i386) and the bug is there too. Checked in 4.1.2 on x86_64 and the bug is NOT there. -- star of file aa.cpp struct A { unsigned int e; }; A a = {1}; double f[] = {0.0461109, 0.285433}; int main(void) { for (bool bEncore = true; bEncore; ) { bEncore = false; double p = 0.422244 * f[a.e]; // double p = 0.422244 * f[1]; if (f[0] < p) { f[0] = p; bEncore = true; } } return 0; } -- end of file aa.cpp g++ -O3 aa.cpp ./a.out --> goes into infinite loop -- Summary: Optimizations generate incorrect code Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: macracan at yahoo dot com GCC build triplet: GNU/linux i386/i686 GCC host triplet: GNU/linux i386/i686 GCC target triplet: GNU/linux i386/i686 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33611