const-correctness , and high levels of compiler warnings should do a lot of what you ask. Also specify a very strict modern C ++ dialect for the compiler (which can annoy you when you use third-party libraries and code that do not match)
If not, then there are many static analysis tools, some of which are open source, some expensive, such as Coverity, Parasoft C ++ Test, etc.
source share