3 ms·
If I understood it correctly, it just turns undefined behavior regarding aliasing into compiler errors
by maikklein_dev 7y ago
If I understood it correctly, it just turns undefined behavior regarding aliasing into compiler errors
- GolDDranks 7y agoNo, it doesn't. There's a set of rules that are proven to have a set of desirable properties (from the viewpoint of compiler optimisations and programmer freedom, in a reasonable balance), and an accompanying interpreter that checks those rules, and turns undefined behaviour regarding aliasing into _runtime_ errors.
- hyperman1 7y agoMy take on this: There are certain properties all rust code should have. In safe rust, the compiler gives a mathematical proof this is so. In unsafe code, the compiler does not, but still assumes these properties are holding. The burden to make sure everything is correct falls on the shoulders of the programmers. But nobody knows exactly what these properties are. There is a big part known, but the edges are fuzzy. So unsafe code is required to follow rules nobody knows. This effort is part of the work to clarify the rules. If accepted, both the compiler and unsafe programmer knows how far they are allowed to go
- littlestymaar 7y agoThat's a really good summary, thank you.
- notriddle 7y agoNo, it doesn't. Stacked Borrows can only be checked at runtime. What it is, is a formal specification for something like an UB Sanitizer.