Computer Chess Club Archives


Search

Terms

Messages

Subject: The compiler is wrong sometimes (was Re: GCC 2.95 big step forward)

Author: Paul J. Messmer

Date: 14:39:29 08/07/99

Go up one level in this thread


On August 07, 1999 at 16:44:40, Robert Hyatt wrote:

>I see this _all_ the time.  Just because a program runs correctly, doesn't
>mean it is a correct program.  Bad memory references can luckily land on
>variables that don't mind getting overwritten, or which have a value of 0.
>Uninitialized variables (local) can be fortunate that they luck into a zero
>on the stack, until some new optimization changes this.  Etc...
>
>Blaming the compiler is wrong, 99.99999999% of the time...
>

Your point about correct runtime performace having no reflection on program
correctness is so true.  However, let me offer a slighly different perspective
on this, from someone who has commerical development with code of reasonable
compuational complexity (but this was using "commercial" compilers, I cannot
speak to the (probably higher :) stability of gcc).  For reasonably modern (but
still somewhat anecdotal) evidence, I would say that in the last five years I
have taken millions of lines of code that was "working" and compiled it under a
new compiler, or on a new platform and a new compiler.  Out of the subsequent
run-time errors that arose, I would say that fully half of them were actually a
result of the compiler (optimizer) producing incorrect code.  Off the top of my
head I can remember pounding my head into the wall tracking down and working
around at least nine such issues, on varying platforms and six compilers:
macintosh, dec alpha, and x86 (like every iteration of MSVC I've used :)

Granted, in the other half of the cases the transition brought to light a latent
problem in the code that had been previously masked by the compiler.  But I
would not be so quick to dismiss possible compiler issues if a run-time problem
arises with the optimizer on that did not exist under a different optimizing
compiler.  Years of experience and investigation indicate issues like these
deserve careful inspection to determine the true culprit.  Who knows what the
real ratio would be, had we some statistically valid results.  But I'm thinkin'
that 99.99999999% percent isn't anywhere close to being within *my* compiler
confidence interval. :)

---
Paul J. Messmer
http://www.spootopia.com
messmer@netcom.com



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.