Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: need an advice how to detect a bug

Author: Pham Minh Tri

Date: 03:40:14 11/04/02

Go up one level in this thread


On November 03, 2002 at 13:47:57, Vincent Diepeveen wrote:

>On November 03, 2002 at 12:23:50, Russell Reagan wrote:
>
>Do you have an assert for every index in your program?
>
>If not then a boundschecker might be an idea to try as well :)
>
>>What I usually do to find bugs is use the assert() macro (in assert.h, or you
>>could write your own). Basically what you do is you assert things you know
>>should be true, such as an index into an array being in bounds. If it's false,
>>your program will halt and let you know where the error occured. For example:
>>
>>assert(i < MAX_VALUE);
>>myArray[i] = SomeFunction(x);
>>
>>That way, when you run the program, it will make sure that i is within bounds.
>>The cool thing about this is that it only does this in debug mode. In release
>>mode the assert()'s go away, so there is no speed penalty. In my programs I go
>>crazy with asserts, and put them all over the place, and it helps find some bugs
>>I wouldn't have found without the asserts. Yes, it will run slower in debug
>>mode, but the point of debug mode is to find bugs, not to run fast.
>>
>>Russell

I agree that use of asserts in everywhere is one of the best experiences to
share (including check bounds). Sometimes my new changes can trigger some dozens
of asserts. Without asserts, my program can run two times slower in debug mode,
but now, it is 20-30 times (in term of nodes per second) as slow as it in
release mode. The big benefit is I can fast develop program, try many new ideas
without worrying much about new errors.

One of amazing thing to me is that I don't find out asserts in Crafty. So I
guess Bob used a special program to clean up the developing versions before
releasing.
Bob, is it correct? Thanks :)




This page took 0.01 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.