@Kimota94 @slava There are some C++ static analyzers that can help (and IIRC, generally do catch this particular problem fairly consistently).
But, it turns out at retrofitting static checks onto an existing language is much harder (and more heuristic-driven) than making the static checks part of your language.
Rust and Idris compilers can prevent whole classes of bugs, at least until you you _ask_ to be exposed to them. (`unsafe`, `believe_me`, `panic`, `idris_crash`).
But also, trying to move an large existing code base over to a new language is almost always long and painful and very hard to make "value-driven" or reflected in your KPI.