Well, I would argue that the alternative is to treat the original program (after translation to Rust) as having Undefined Behavior.
There are, to my knowledge, generally two reasons why people might want to transmute a pointer to an integer:
- Chaining many `as` casts is annoying, so calling `mem::transmute` might be shorter.
Well, I would argue that the alternative is to treat the original program (after translation to Rust) as having Undefined Behavior.
There are, to my knowledge, generally two reasons why people might want to transmute a pointer to an integer:
- Chaining many `as` casts is annoying, so calling `mem::transmute` might be shorter.
The first kind of code should just use `as` casts, and we should do what we can (via lints, for example) to identify such code and get it to use casts instead.[^compat]
Maybe we can adjust the cast rules to remove the need for chaining, or add some [helper methods](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.expose_addr) that can be used instead.
The first kind of code should just use `as` casts, and we should do what we can (via lints, for example) to identify such code and get it to use casts instead.[^compat]
Maybe we can adjust the cast rules to remove the need for chaining, or add some [helper methods](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.expose_addr) that can be used instead.