Headache? More like a morass from which we will never get out of, unless we learn to use Formal Methods techniques to have AI generate code using a correct-by-construction approach. Classic ideas from Floyd/Hoare/Dijkstra/Meyer are the key techniques to use before moving on to heavyweight techniques like model-checking/theorem-proving etc.
We need to build on this; Correctness-by-Construction: An Overview of the CorC Ecosystem - https://dl.acm.org/doi/10.1145/3591335.3591343