28 Jan, 2009
Make sure to have 0 warnings.

Making sure you have 0 warnings is good advice. Unfortunately, I’m not perfect, and in one of my current projects, I have a pretty big list of warnings that I know are not important.
Today, I got bitten by not following the 0 warnings advice. I searched for a bug for over an hour. Let’s see if you can spot the mistake:
if (m_holdingMessages); { Log.Msg("Holding messages in queue"); msgQueue.Enqueue(msg); return true; }
The if statement always executed. m_holdingMessages should have been false, and I was pretty sure it was false, but the code executed anyway. Being the witty reader of this blog that you are, naturally you immediately spotted the erronous semi-column after the if statement. It got there accidentally, but funny enough the resulting code is valid c#. It’s silly c#, but valid.
Naturally, Visual Studio, (and Unity) give warnings when compiling this. They say: “Possibly mistaken empty statement”. Dead on.
But I missed the warning, because it drowned in all those warnings I had been ignoring all that time.
Had I been a good boy, I would have made sure I had no warnings at all, and this one waring would have gotten my attention, and I could have spent my morning drinking coffees instead of looking for this silly bug.