Earlier quoted context omitted.
This is simply not true. Almost all optimisations rely on undefined behavior, see https://news.ycombinator.com/item?id=38760475 Note that I am not talking about UB like signed integer overflow. Removing that would slow down programs by a couple of percent. The important type of UB is pointer provenance. This ensures that e.g., writing to a random memory address is UB.
Almost all optimisations in C/C++ compilers depend on undefined behaviour, because practically no behaviour is defined! The trick is to define behaviour, which is what other programming languages do. E.g.: in both C# and Rust, integers have fixed sizes. A C# Int32 is equivalent to a Rust i32. Only God knows what a C/C++ "int" is. It could have 17 bits and use ternary.
Re: Memory safety is necessary, not sufficient
#161As I said, this isn't about ints, it's about pointers. What behavior will you define in C for writing to a random memory address?