I'm realistic about the limits of AI** but a really strict C++ compiler, making use of 'AI'*, could mitigate a lot of those problems by enforcement. Rust is good but usual caveats apply.
https://www.theregister.com/2023/12/07/memory_correction_five_eyes/?td=rt-3a
* Linear algebra and modern processing power.
** and we haven't gotten to the lawsuits yet.