We have all used tools like
purify for automated leak detection, out of bounds memory access, free memory reads etc (essentially certain types of code patterns which are considered as bugs). These tools are great productivity enhancers and cost savers since we can and fix more bugs before the product reaches the customer.
However, there are a lot of other bugs like deadlocks, race conditions, resource leaks like unfreed sockets, database connections etc which are hard to find and generally can be hit at customer deployments which are costly both for the customer and the software vendor. Such bugs can also be auto-detected using static analysis and dynamic analysis to some extent. There are two hard problems though:
1) The algorithms do not scale well for large code bases, and
2) The number of "false positives" tends to be very high in static analysis.
However several people have now worked on these problems and have come up with usable tools. e.g
Coverity. It will be that you run a tool like this from your IDE once you want your code to be checked and viola you get quality bugs reported in a small time.