by Ionitor » Jun 13, 2002 @ 11:14pm
I had a problem that I had been working on for my own interest when I was first teaching myself C++. I developed a templated class for the problem because it was a large numerical problem, and could conceivably need larger-than-64-bit integers later in the game.
Well, my class had some stupid little bug in the code to travel and operate on a binary tree. I can no longer remember the exact bug, but it seemed straightforward enough at the time. I fixed it, recompiled, and the same bug popped up. I thought, "Well, there must be a different bug somewhere else in the code." I looked around, found a few bugs here and there, but nothing that would fix the problem. I spent few days working on it, then finally gave up, since it was just for my own interest and I had more important things to spend my time on.
A year or so later, I looked back at the program. The bug still didn't make any sense, so I spent some more time stepping through the code. Eventually, I noticed that the debugging code I had put in wasn't running--I would create a variable, increment it, and the variable never seemed to exist. Finally, I came to the conclusion that the code I was looking at was not the code in the program. It turned out that Visual C++ 4.0 had a bug in it that would ignore changes to template class files, so after any changes, you needed to use the "clean" command before recompiling.
Since then, the first thing I do whenever there's a difficult bug is just recompile my whole program. It continues to save me hours of problems to this day, even with the most current compilers.
-Ionitor