A note about
= vs ==, a good
compiler should be able to catch this one. For instance,
CodeWarrior (one of the two major
MacOS compilers) will warn you if you do something like
if( a = 5 ) { do_stuff(); }
. However, it's fine with
if( (a = 5) ) { do_stuff(); }
, so you won't have to wade through warning messages when you do want to
assign a value.
Similarly, it will pick up
a == 5;
without an
if
, but I don't think too many people make that
error.
As far as the most
elusive type of problem goes, I have to concur with the general conclusion here:
memory leaks. An unassigned pointer or buffer overflow
crashes sooner or later (probably sooner), and that tends to give you a good idea of what is causing it and where it is. Hunting it down tends to be fairly direct, if time consuming, because you know where to look. They can be
nasty as hell, but they aren't usually very elusive.
Memory leaks, on the other hand, don't give you any
warning. Unless you specifically look for them by keeping track of
allocated and
freed memory, you won't even know they exist. Once you do determine that you're leaking memory, you really have no idea where to start looking. They aren't impossible to fix or particularly nasty, but they are elusive.