2 ms·
I'd love an explanation of how bool bit validity causes undefined behavior. Does the compiler emit "jump if equal to 1" instructions instead of "jump if equal o
by throwup238 2y ago
I'd love an explanation of how bool bit validity causes undefined behavior. Does the compiler emit "jump if equal to 1" instructions instead of "jump if equal or above 1" when comparing operands?
- kam 2y agoThe reserved values can be used as tags in outer enum types. For example `Option<bool>` might encode `None` as 2. If you did `Some(transmute::<bool>(2))` it'd turn into `None`.
- steveklabnik 2y agoUB has nothing to do with what the compiler emits. It's undefined behavior because the language says it's undefined behavior. That said, "what may happen in practice" can be an interesting question, but any answer cannot be relied on to be the case, because it may change at any time. Looks like my sibling already gave you a possible thing that may happen.