Computer Chess Club Archives


Search

Terms

Messages

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

Author: José de Jesús García Ruvalcaba

Date: 10:13:39 08/08/99

Go up one level in this thread


On August 08, 1999 at 13:02:32, Vincent Diepeveen wrote:

>On August 08, 1999 at 12:54:10, José de Jesús García Ruvalcaba wrote:
>
>>On August 07, 1999 at 17:39:29, Paul J. Messmer wrote:
>>
>>>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 :)
>>>
>>
>>	Now I think, if I ever write a chess engine I will develop it simultaneously in
>>two different platforms. That will drastically reduce the number of bugs hidden
>>by the compilers. And it is not very difficult to write portable code, it only
>>requires some discipline.
>>José.
>
>I compile with 4 different compilers
>  windows
>    - msvc
>    - watcom
>    - intel
>
>  linux/unix (intel/sun)
>    - gcc
>

	I do not think gcc is a good compiler for Sparc/Solaris. In my experience cc
produces far better code. Somebody told me that gcc is better than cc, but never
showed hard facts. My experience can be wrong, as I might have not got the best
from gcc, but I have nothing better than my own experience to rely on.

>There are a lot of gcc derivates like pgcc, but they all produce the same
>code on the different machines.
>
>First time i tried intel compiler was great. Removed some array lookups
>in my evaluation to array[-1] as i forgot a lot of times that
>on the board there could be a lot of queens.
>
>Weirdly those references weren't reported by a single compiler,
>a single tool, and didn't produce a byte difference in the huge
>verbose files (around a few hundred mb each depending upon how many
>seconds i let it search, half a minute produces already 50mb)
>
>Weird that only internal intel compiler found that for me.
>

	I will take note of this Intel compiler.

>
>
>>>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.