## Undefined Behavior in Rust
Coming back to Rust, where are we at?
## Undefined Behavior in Rust
Coming back to Rust, where are we at?
For example, what if unsafe code crafts two aliasing mutable references (something that is prevented in safe Rust) and passes them to our `simple` function?
This violates the assumptions we made when we reordered the two writes.
If we want to permit this optimization (which we do!), we have to argue why it cannot change program behavior.
For example, what if unsafe code crafts two aliasing mutable references (something that is prevented in safe Rust) and passes them to our `simple` function?
This violates the assumptions we made when we reordered the two writes.
If we want to permit this optimization (which we do!), we have to argue why it cannot change program behavior.
To this end, the specification should be written in a way that such tooling is feasible.
In fact, specifying a dynamic UB checker is a very good way to specify UB!
Such a specification would describe the additional state that is needed at run-time to then *check* at every operation whether we are running into UB.
To this end, the specification should be written in a way that such tooling is feasible.
In fact, specifying a dynamic UB checker is a very good way to specify UB!
Such a specification would describe the additional state that is needed at run-time to then *check* at every operation whether we are running into UB.