C++ UB and compiler optimizations

So something new that I learned that C++ compiler is free to optimize away any behaviour which is UB and thus cannot happen for example…