logoalt Hacker News

AlotOfReadingyesterday at 11:27 AM2 repliesview on HN

That's not actually sufficient in the general case where the pointer may not be the type of the underlying object. You also have to respect strict aliasing even if the bounds are correct. This isn't true in the same way in Rust because memory is untyped. You only need to ensure basic memory validity (range, initialization, alignment, etc).


Replies

ueckeryesterday at 12:31 PM

Yes, you also do not want to do random casts, but this is even easier. I do not get your point out memory validity in Rust. What if you write where a pointer is stored, or even a boolean?

show 1 reply
zozbot234yesterday at 12:44 PM

Rust has pointer provenance which implies very similar constraints to the "typed memory" wording of C/C++.

show 2 replies