3 ms·
Technically, code that contains UB is just UB, and unsound code is code that allows you to trigger UB using safe code only. For example, this is UB: unsafe
by afdbcreid 5y ago
Technically, code that contains UB is just UB, and unsound code is code that allows you to trigger UB using safe code only.
For example, this is UB:
unsafe { std::hint::unreachable_unchecked() };
And this is an unsound code, that may not contain any UB if I call `unsound()` with `false`:
fn unsound(trigger: bool) {
if trigger { unsafe { std::hint::unreachable_unchecked() }; }
}