|
|
|
|
|
by nicoburns
1129 days ago
|
|
That is not what UB means. Undefined Behaviour is behaviour that the compiler is allowed to assume will never happen, and which can consequently cause miscompilations due to optimisation passes gone wrong if it does in fact occur in the source code. It's true that Rust does not have a written specification that clearly delineates what is and isn't UB in a single place. But: 1. UB is impossible in safe code (modulo bugs in unsafe code) 2. There are resources such as the Rustinomicon (https://doc.rust-lang.org/nomicon/) that provide a detailed guide on what is and isn't allowed in unsafe code. In practice, it's much easier to avoid UB in Rust than it is in C++. |
|
Based on that definition it feels like it should be possible to have UB outside of memory violations, is there really no UB in languages like Java/Haskell/Go?