1.2 Classifying a bug
Despite the appearance, bugs have often a common background. This allows to attempt a quite coarse, but sometimes useful, classification. The list is arranged in order of increasing difficulty (which fortunately means in order of decreasing frequency).
Syntactical Errors should be easily caught by your compiler. I say "should" because compilers, beside being very complicated, can be buggy themselves. In any case, it is vital to remember that quite often the problem might not be at the exact position indicated by the compiler error message.
Build Errors derive from linking object files which were not rebuilt after a change in some source files. These problems can easily be avoided by using tools to drive software building.
Basic Semantic Errors comprise using un initialized variables, dead code (code that will never be executed) and problems with variable types. A compiler can highlight them to your attention, although it usually has to be explicitly asked through flags (cp. 2.1).
Semantic Errors include using wrong variables or operators (e.g., & instead of && in C++). No tool can catch these problems, because they are syntactically correct statements, although logically wrong. A test case or a debugger is necessary to spot them.
A funny physical classification distinguishes between Bohrbugs and Heisenbugs. Bohrbugs are deterministic: a particular input will always manifest them with the same result. Heisenbugs are random : difficult to reproduce reliably, since they seem to depend on environmental factors (e.g. a particular memory allocation, the way the operating system schedules processes, the phase of the moon and so on). In C++ a Heisenbug is very often the result of an error with pointers.
1.3 Understanding a bug
A bug should be fully understood before attempting to fix it. Trying to fix a bug before understanding it completely could end in provoking even more damage to the code, since the problem could change form and manifest itself somewhere else, maybe randomly. Again, a typical example is memory corruption: if there is any suspect memory was