Your message dated Wed, 10 Aug 2005 00:40:08 +0200 with message-id <[EMAIL PROTECTED]> and subject line Bug#322218: gcc -O2 optimization bug has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what I am talking about this indicates a serious mail system misconfiguration somewhere. Please contact me immediately.) Debian bug tracking system administrator (administrator, Debian Bugs database) -------------------------------------- Received: (at submit) by bugs.debian.org; 9 Aug 2005 19:21:26 +0000 >From [EMAIL PROTECTED] Tue Aug 09 12:21:26 2005 Return-path: <[EMAIL PROTECTED]> Received: from space.mit.edu [18.75.0.10] by spohr.debian.org with esmtp (Exim 3.36 1 (Debian)) id 1E2ZfC-0007UU-00; Tue, 09 Aug 2005 12:21:26 -0700 Received: from vex.mit.edu (vex [18.75.2.33]) by space.mit.edu (8.12.10/8.12.10/csr-3.2.5) with ESMTP id j79JLOvN018954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <[EMAIL PROTECTED]>; Tue, 9 Aug 2005 15:21:25 -0400 (EDT) Received: from vex.mit.edu (localhost [127.0.0.1]) by vex.mit.edu (8.13.4/8.13.4/Debian-3) with ESMTP id j79JLOEx005737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <[EMAIL PROTECTED]>; Tue, 9 Aug 2005 15:21:24 -0400 Received: (from [EMAIL PROTECTED]) by vex.mit.edu (8.13.4/8.13.4/Submit) id j79JLO4T005735 for [EMAIL PROTECTED]; Tue, 9 Aug 2005 15:21:24 -0400 From: John Houck <[EMAIL PROTECTED]> Date: Tue, 9 Aug 2005 15:21:24 -0400 To: [EMAIL PROTECTED] Subject: gcc -O2 optimization bug Message-ID: <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Delivered-To: [EMAIL PROTECTED] X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 (1.212-2003-09-23-exp) on spohr.debian.org X-Spam-Level: X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE autolearn=no version=2.60-bugs.debian.org_2005_01_02 Package: gcc Version: 3.3.5-3 When compiled with -O2, the appended test program goes into an infinite loop at run-time. When compiled with -O or with no optimization, it runs correctly, exiting immediately and generating no output. I am using Debian GNU/Linux 3.1, with a 2.4.28 kernel and libc6-2.3.2.ds1-22 #include <math.h> #include <float.h> #include <stdio.h> /* gcc optimization bug * * Problem: Program goes into an infinite loop when * compiled with -O2 optimization. * * compile: gcc $OPT bug.c -lm * run: ./a.out * * gcc -O bug.c -lm => works with 2.95.4, 3.3.5, 3.4.4, 4.0.0 * gcc -O2 bug.c -lm => infinite loop with 3.3.5 and 3.4.4 * => works with 2.95.4 and 4.0.0 */ static int bisection (double (*func)(double, void *), double a, double b, void *cd, double *xp) { unsigned int count = 1; unsigned int bisect_count = 5; double fa, fb; double x = a; if (a > b) { double tmp = a; a = b; b = tmp; } fa = (*func)(a, cd); fb = (*func)(b, cd); if (fa * fb > 0) { *xp = a; return -1; } while (b > a) { double fx; if (fb == 0.0) { x = b; break; } if (fa == 0.0) { x = a; break; } if (count % bisect_count) { x = (a*fb - b*fa) / (fb - fa); if ((x <= a) || (x >= b)) x = 0.5 * (a + b); } else x = 0.5 * (a + b); if ((x <= a) || (x >= b)) break; fx = (*func)(x, cd); count++; if (fx*fa < 0.0) { fb = fx; b = x; } else { fa = fx; a = x; } } *xp = x; return 0; } static double f (double x, void *cd) { (void) cd; return x - cos(x); } int main (void) { double x; (void) bisection (&f, 0.0, 1.0, NULL, &x); if (fabs(f(x,NULL)) > DBL_EPSILON) fprintf (stdout, "Error\n"); return 0; } --------------------------------------- Received: (at 322218-done) by bugs.debian.org; 9 Aug 2005 22:40:40 +0000 >From [EMAIL PROTECTED] Tue Aug 09 15:40:40 2005 Return-path: <[EMAIL PROTECTED]> Received: from smtp06.web.de [217.72.192.224] by spohr.debian.org with esmtp (Exim 3.36 1 (Debian)) id 1E2cm0-0007qM-00; Tue, 09 Aug 2005 15:40:40 -0700 Received: from [84.59.228.147] (helo=juist) by smtp06.web.de with asmtp (TLSv1:DES-CBC3-SHA:168) (WEB.DE 4.105 #314) id 1E2clU-0002zX-00 for [EMAIL PROTECTED]; Wed, 10 Aug 2005 00:40:08 +0200 Received: from falk by juist with local (Exim 4.52) id 1E2clU-0007du-Sy for [EMAIL PROTECTED]; Wed, 10 Aug 2005 00:40:08 +0200 To: [EMAIL PROTECTED] Subject: Re: Bug#322218: gcc -O2 optimization bug References: <[EMAIL PROTECTED]> From: Falk Hueffner <[EMAIL PROTECTED]> X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2<T^ Date: Wed, 10 Aug 2005 00:40:08 +0200 In-Reply-To: <[EMAIL PROTECTED]> (John Houck's message of "Tue, 9 Aug 2005 15:21:24 -0400") Message-ID: <[EMAIL PROTECTED]> User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.5 (cilantro, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: [EMAIL PROTECTED] X-Sender: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 (1.212-2003-09-23-exp) on spohr.debian.org X-Spam-Level: X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER autolearn=no version=2.60-bugs.debian.org_2005_01_02 John Houck <[EMAIL PROTECTED]> writes: > When compiled with -O2, the appended test program goes into an > infinite loop at run-time. When compiled with -O or with no > optimization, it runs correctly, exiting immediately and generating > no output. This is caused by excess precision of the x87 FPU and therefore slightly different rounding depending on optimizations. Your options are: * Write more robust code * Use SSA floating point * Use -ffloat-store * Don't use x86 -- Falk -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]