C++26 and C++29 are in the process of turning a lot of that UB into erroneous behaviour, basically what safer languages have been doing for ages.
However, how many years it will take until those versions become widely deployed across major compilers, and used by developers?