3 ms·
For unrelated reasons, I wonder how strong Rust's runtime types are. That is, assuming you manage to compile something with undefined behavior, will the program
by Kinrany 6y ago
For unrelated reasons, I wonder how strong Rust's runtime types are. That is, assuming you manage to compile something with undefined behavior, will the program crash immediately?
- ithkuil 6y agoRust undefined behavior can only happen within "unsafe" blocks. You can read more about what things the programmer has to manually avoid while writing code in "unsafe" code blocks: https://doc.rust-lang.org/reference/behavior-considered-undefined.html https://doc.rust-lang.org/reference/behavior-considered-unde... EDIT: this means that if you stick to safe rust, the type system ensures you cannot have data races (among other things)
- Kinrany 6y agoI do mean the unsafe blocks.
- tom_mellior 6y agoIt won't necessarily crash immediately. Inside unsafe blocks you can invoke undefined behavior by overwriting arbitrary memory locations. The effects of reading that modified memory (including crashes) can become visible much later, long after the unsafe block.