I've been having big problems in reproducing and finding the cause of a bug. The occurence seems entirely random, so I suspected an uninitialized variable somewhere. But then I found this piece of code:
CMyClass obj; // A
obj.DoStuff();
if ( somebool )
{
CMyClass obj; // B
obj.DoStuff();
}
obj.DoOtherStuff();
It seems as though DoOtherStuff() is either done on "B", or that B.DoStuff() sometimes actually works on A - i.e. i DoStuff() is actually called on the first obj.
Could this happen? I don't think I got a compiler warning (I've fixed the code now in hoping that it might help). It seems very likely that this piece of the actual code is where the bug I'm trying to find is, but there could of course be other reasons I haven't discovered yet.