For Turing-complete languages we cannot reliably decide offline whether a program has the potential to execute an error; we have to just run it and see
Diverse Anleitungen und Tipps um C++ oder Assembler Code zu optimieren
Eine VIelzahl an Informationen zu Sicheres Programmieren, zusammengestellt von cert.org