Author: Christophe Theron
Date: 06:33:10 12/09/01
Go up one level in this thread
On December 09, 2001 at 04:06:27, Lex Loep wrote:
>On December 08, 2001 at 10:44:54, Christophe Theron wrote:
>
>>On December 08, 2001 at 04:16:46, Lex Loep wrote:
>>
><<SNIP>>
>>
>>I have found this bug a while ago.
>>
>>I had a bit of code that exchanged the higher and lower bytes in a word. It was
>>programmed in a single expression and the compiler generated wrong code for it
>>when some optimizations were turned on.
>>
>>Downloading the latest service pack (SP5) did not solve the problem. 13 hours of
>>download for nothing, I was happy as you can imagine.
>>
>>Splitting the code in two lines solved the problem.
>>
>>The common point between your code and mine is that we are both using a shift
>>operation combined with an or operation.
>>
>
>In our case it was the ordering of the "if (P1==0) " line. We looked at
>the assembly code and found it was using the wrong register to do the
>P1==0 thing, in effect the compare turned into P2==0.
>I think it is releated to byte size operations.
Yes I remember that from looking at the assembly code it was also using the
wrong register.
>>This is a common thing in any C program, so I feel very uncomfortable with this
>>compiler bug.
>>
>>
>
>That was my main reason to post here.
>
>Still the compiler is quite good, this is the first time we found a bug in
>this version. The older 16 bit compilers where much worse.
I still have to find a bug the in code generated by the GCC 2.95.2. Maybe it has
bugs, but I have never encountered one since I use this compiler for the DOS
version of Chess Tiger which I'm working on daily since 1997.
Anyway I think the best protection I have against compiler bugs is to use
several compilers.
I compile the Chess Tiger engine with GCC and MSVC, then I let it chew a set of
positions. I compare the total number of nodes computed. It must be exactly the
same. If it is not, I hunt the problem until I find where the difference comes
from.
Then I also compile Tiger with the 68000 version of GCC (Palm version) and do
the same test. The engine is identical, so the output must be identical.
My assumption is that it is extremely unlikely that the same compiler bug will
appear in 2 different compilers.
Christophe
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.