Three notes:
1. The SafeInt class helps detecting integer overflows:
Also, most SafeInt binary operators do not allow for mixing of SafeInts for different integer types.
2. Valgrind helps with detecting use of uninitialized memory.
3. A (rather ugly) solution to prevent accidental use of = rather than == when a constant expression is used, is to make the constant expression the first operand. E.g.:
if (0 = x) // fail!