News for hackers. Stuff that matters.
Re:The Tower of Weakenings: Memory Models for Everyone by seo-speedwagon on Wednesday April 06, 2022 @01:50PM (#30935303)
This is my question as well. I don't write a lot of C or Rust code, so I'm curious when int -> ptr and ptr -> int conversions are actually needed in practice. The only scenarios I can think of with my limited domain experience in are low-level things where you actually know the numeric addresses of certain important locations in memory. In which case, saying "yeah, that's a lower level in the weakenings tower" seems sensible.
Re:The Tower of Weakenings: Memory Models for Everyone by mh7 on Wednesday April 06, 2022 @02:29PM (#30935735)
A classic example is when you're writing a custom allocator and need to align the address.

Another is storing pointers in a hash table - you need to do arithmetic on the pointer bits to compute the hash.

Re:The Tower of Weakenings: Memory Models for Everyone by Gankra on Wednesday April 06, 2022 @03:00PM (#30936136)
I already designed several new convenience methods for making this kind of thing simple and the PR to rust-lang is already open :)