News for hackers. Stuff that matters.
Re:Safety Goggles for Alchemists: The Path Towards Safer Tra... by throwup238 on Friday October 04, 2024 @03:44PM (#41744929)
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?
Re:Safety Goggles for Alchemists: The Path Towards Safer Tra... by steveklabnik on Friday October 04, 2024 @04:00PM (#41745055)
UB 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.

Re:Safety Goggles for Alchemists: The Path Towards Safer Tra... by kam on Friday October 04, 2024 @04:00PM (#41745050)
The 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`.