I wonder if there is (or could be) a program that collates the most common bugs for X programming language from SO. So you run it as a sort of preprocessor, and it picks up stuff that the compiler either doesn't or can't.
Not related to SO, but FindBugs and PMD for Java are designed to identify potential bugs, based on accumulated knowledge of "gotchas" (e.g. calling "multiply()" on a BigDecimal without assigning it to a new variable - BigDecimal is immutable).