Author: Vincent Diepeveen
Date: 10:47:57 11/03/02
Go up one level in this thread
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
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.