Re:Let rand = main as usize
by blt on Thursday June 06, 2024 @03:19PM
(#40601308)
In that case, then a linter warning seems more appropriate for pointer->int than requiring "unsafe". I feel "unsafe" should not be diluted to mean "unwise". But what do I know, I'm a C++ programmer...
[ Parent
| on HN ]
Re:Let rand = main as usize
by sans-seraph on Thursday June 06, 2024 @04:06PM
(#40601781)
Rust's linting tool, Clippy, provides a lint that will produce a warning when a function pointer is cast to any integral type: https://rust-lang.github.io/rust-clippy/master/index.html#/f...
The broader topic of whether it is safe, or wise, to cast between pointers and integers in general is an area of active research. Ralf Jung's blog is required reading on this topic: https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html