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.
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.
For a background, see Taming Undefined Behavior in LLVM.
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.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.Tangent related to UB: What should the result of sqrt(-1) be?