|
From: | Mats Bengtsson |
Subject: | Re: Infinite loop with GCC 4.3 |
Date: | Mon, 26 May 2008 10:09:05 +0200 |
User-agent: | Thunderbird 2.0.0.5 (X11/20070716) |
comparing numerical values. For example you should use tests of the form if (abs(x-y) < epsilon) instead of if (x==y) where epsilon is a fixed value somewhat larger than machine precisions. Following the same line of thought, you should use if (x >= y - epsilon) instead of if (x >= y ) (though this is probably not mentioned as often in the course text books). and analogously it follows that you numerically cannot distinguish between if (x > y) and if (x >= y) Here you show an example where you cannot rely on if (x > y) but have to do something more or less equivalent to if ( x > y - epsilon) to guarantee numerical stability.I haven't read the corresponding thread in the GCC bug tracker, but I'm sure that these
aspects have been discussed in length there as well. /Mats Joe Neeman wrote:
On Sun, 2008-05-25 at 13:41 +0200, John Mandereau wrote:On 2008/05/23, Joe Neeman wrote:Does re-building without optimisations help?Yes, it does! Building with GCC 4.3.0 and without -O2 flag makes LilyPond produce the same output [*] as with GCC 4.1.2 with optimisations, but it is also (not very surpisingly) much slower, so I'll go on building Lily with GCC 4.1.2, unless Fedora 9 provides an upgrade to a newer and fixed version.Attached is the smallest example that I could find that reproduces the problem. With g++ 4.3.0 on Fedora 9, I get an infinite loop with -O1 but immediate termination with -O0. With g++ 4.2.3 on Debian, I get termination regardless of the optimisation setting. I think it is also easy to argue that the program should terminate, regardless of rounding (the value of 'i' should be the same every time the loop executes. So on the second time through, 'x' should be at least as large as 'i'). Can you reproduce? If so, I'll go bug the gcc people. Joe------------------------------------------------------------------------_______________________________________________ lilypond-devel mailing list address@hidden http://lists.gnu.org/mailman/listinfo/lilypond-devel
-- ============================================= Mats Bengtsson Signal Processing School of Electrical Engineering Royal Institute of Technology (KTH) SE-100 44 STOCKHOLM Sweden Phone: (+46) 8 790 8463 Fax: (+46) 8 790 7260 Email: address@hidden WWW: http://www.s3.kth.se/~mabe =============================================
[Prev in Thread] | Current Thread | [Next in Thread] |