So I had this bit of strange looking code:
if (led->m_to[i] != prev &&
(FCanCrossSelf || !_hit[led->m_to[i]->m_index]));
{
cango.push_back(i);
}
I was having a problem where it was getting into the if statement even
when the condition was supposed to be false. I could not, for the life
of me, figure out what was going on. The condition has so many braces
and arrows and things in it, and I had been staring at it for so long.
Why was it getting into the if statement when the condition was false?
I could print debugging info from inside the statement and verify it
was false. I could step through in my debugger and watch it step into
the statements, even when it evaluated to false. What was going on?
Well it's obvious when I look at it now, but after *over* an hour of
debugging, looking at conditions, looking at other code, checking for
buffer overruns in strange places, I *finally* spotted the damn extra
semicolon I accidentally typed at the end of the "if". See it? It's
right there before that left curly brace.
I slapped myself on the head pretty hard after realizing how dumb the
mistake was. It's not the first time I've spent a long time debugging
a simple syntax mistake like that.
So now, I am taking a break for a few minutes, and I am wondering:
what kinds of horror stories do people here have about silly mistakes
like this one? Hours spent debugging when you typed a j instead of an
i, or put a parenthesis in the wrong spot, an extra semicolon, a
problematic #define. There's got to be some good stories out there!
- AJ