1. 8
    1. 5

      For a background, see Taming Undefined Behavior in LLVM.

    2. 3

      I think it’ll be very important for Rust. Currently it’s forced to inherit Undefined Behavior from LLVM, which means it’s the same as C’s UB, which in many edge cases is not what Rust wants.

      Rust had a bit of a “oh sh*” moment when it looked at UB closer. Miri (UB-checking Rust interpreter) uncovered a few cases of UB in the standard library. mem::uninitialized() was deprecated entirely as it became clear it’s practically impossible to use it without causing some UB.

      And it turns out it’s really really hard if you wan to be strict about UB and avoid all cases not just in practice (as in “maybe it’s UB, but it won’t actually cause problems”), but also entirely eliminate it in theory. There are some fun open questions such as, is it UB if you pass a pointer to a Rust struct to fwrite? If the struct has padding, then the answer is quite complicated.

    3. 2

      This, the the bottom half, may be more informative. Looks like freeze takes an LLVM SSA register and returns a value whose contents are not undefined. So this should allow you to change a radioactive go-back-in-time-and-shoot-your-dog undefined value into harmless garbage.

    4. 1

      Tangent related to UB: What should the result of sqrt(-1) be?

      1. Error-signaling return code in same domain as result
      2. Error-signaling return code, return result in pointer argument
      3. Error-signaling return code, make result a sum-type equilvalent of Either
      4. Throw exception
      5. Abort program
      6. Undefined, make it the caller’s responsibility to not pass in negative values