I don't know many who remember the 16-bit processor days. Back then, we used to always check for overflow conditions because we had to. These were my Magic Candle days, before Zortech came along and gave us access to protected mode - and what a relief that was. Not only did it catch bad pointer writes a huge amount of the time, but 32 bits - finally we can easily express a number higher than 65535!
At first, I kept checking overflow conditions anyway, out of habit. Which takes a while - never mind the CPU time, what about the programmer time?
It wasn't long before I stopped and said - "Wait a minute. Just what are the chances an overflow is going to bite me?"
Take, for example, an incrementing counter, going up every frame. When is that sucker going to overflow? A little quick math - 2 billion divided by 60 fps divided by 60 seconds in a minute divided by 60 minutes in an hour divided by 24 hours in a day ... it's going to take a year for that sucker to overflow.
So I got complacent. In fact - I would even get frustrated with coders on my team who spent time making sure their code was overflow-safe.
Decades later - just the other day - I finally got bitten by an overflow bug. I was using the high-resolution timer API in Windows (which ticks much faster than 60 per frame on most processors), ignoring the high 32 bits, and it worked on my machine, but my machine was not the machine we were demoing the game on publishers to - and because QueryPerformanceCounter is different from processor to processor, the demo machine would get all funky after playing for 15 minutes or so.
Whoops.
Am I going to beat myself up about it, though? Nope. Because this is the only time in my last fifteen or so years of coding that I remember getting bitten by a 32-bit overflow. And with the kind of coding I'm usually doing - prototyping - it is usually not worth spending the time to think about it. My expected value of return on time invested ... it's just not there.
(Though I also realize that in some applications - like where a malicious user could get at your data - it suddenly becomes very important again.)
What about y'all? Are there certain types of bugs or correctness that you just don't sweat about?
Recent Comments