Yesterday, I had a bug in my program where I couldn't figure out why it was happening. It was reproducible, but made no sense. The debugger showed the program did the right thing but the output wasn't correct. So I debugged the program for about 30 minutes, until I gave up.
Then, I cleaned the built object files and rebuilt the whole project from scratch. TADA. Bug disappeared. *grml*
I know, this happens from time to time. The built executable gets corrupted somehow and a rebuild helps. But this time I swear: I'll remember: If it makes no sense, rebuild FIRST! :)
eleven comments, already:
I know that kind of problem, and was (in my case) able to track it down to be a combination of changed struct/class sizes and lack of proper build dependencies -> part of the code were built with the “old” assumptions about an object’s size/structure, parts were rebuilt with the “new” assumptions, which led to crashes and/or other weird behaviour when “old” and “new” code interacted.
ak () - 02 07 10 - 14:55
Yup; I’ve noticed this immensely when developing iPhone apps – if you’re PC is fast enough and the project is small enough it helps to just always clean before a build or make sure to clean out the build directory every hour or so .
Chris () (link) - 02 07 10 - 15:29
Isn’t this more of a compiler problem than a C++ problem?
rip - 02 07 10 - 15:50
I can only say “amen”!
giggsy () (link) - 02 07 10 - 16:10
Been bitten by that more than once in console development.
If any part of the build dependencies is not checked 100% correctly, you’ll most probably violate the ODR (one-definition-rule), eventually resulting in a crash.
tiv - 02 07 10 - 16:58
Never experienced that. Sounds like a compiler bug…
DrHalan - 02 07 10 - 18:51
Qt SDK aways give me this problem.
Virion () (link) - 02 07 10 - 21:09
Speaking of difficult bugs…
When I was porting Emacs to the iPhone, I kept getting random segfualts everywhere. Once I cleaned up the build enough to get debugging symbols (the final emacs binary is a memory dump of a semi-compiled version, ugghh), I found out the segfaults were all caused by system calls. ~4 hours later, I find out my system headers were subtly wrong, so these syscalls kept overwriting memory that wasn’t allocated.
agrif - 02 07 10 - 23:57
my gold rule with vs and xcode : clean, always! :D and i have a doubt, another clean may help
garixi - 03 07 10 - 00:52
Here at work I clean everything every morning and rebuild, but at home I only do that when some strange error occurs.
One the other hand: the most annoying bug in the last year was switching my Stunt Marble Racers project from 2 player splitscreen to up to 4 player network: I forgot to resize an array. No crash, it just overwrote some other data leading to strange behaviour. Took me quite some time to figure that out.
Brainsaw (link) - 05 07 10 - 07:31
KIENI - 05 07 10 - 08:53