3 ms·
This comment would be significantly improved by fully spelling out what UB is at least once.
by appplication 3y ago
This comment would be significantly improved by fully spelling out what UB is at least once.
- kmeisthax 3y agoUndefined behavior means the compiler will rewrite your program in ways that do not follow from the meaning of the source code. This means things like conditions and guards just disappearing, code being reordered in ways that don't make sense, and so on. All of the safety guarantees of Rust go out the window once UB is triggered, because everything goes out the window. Which is why Rust is designed so that safe code can't trigger UB. But unsafe code still has to worry about it.
- jenadine 3y ago> the compiler will rewrite your program in ways that do not follow from the meaning of the source code. It's not that, it's just that the source code has no meaning for a particular code path, so the compiler can do anything so that other code paths or conditions can be faster/more optimized. Just nitpicking.