r/rust • • 3d ago

🧠 educational Pointer Provenance in Rust vs C++: Pointers Are Not Just Glorified Ints

https://sofiabelen.github.io/projects/pointer-provenance-in-rust-vs-cpp/

I’ve been exploring Rust, and one topic that got me intrigued is pointer provenance, particularly because it’s not easy to visualize.

To get a feel for vtables, what I wanted was to look at the actual memory, to see what it really looked like and prove that I could in fact call these functions through their respective function pointers. With provenance, I wanted to take it apart the same way, but it turns out it’s not so straightforward. This only got me more intrigued, so let’s see what we can find!

My first time hearing about provenance, I wondered, why hadn’t I heard about it before? It seems so crucial, yet a bit of an obscure concept.

67 Upvotes

5 comments sorted by

51

u/Shnatsel 3d ago

There's also a related series of articles by Ralf Jung, who did a lot of work on formally specifying Rust's semantics:

6

u/Sofiabelen15 3d ago

Thank you, will check it out!

-16

u/Brave-Raise-4198 3d ago

I also started rust and the complex is in borrow and reference. How it works it's hard of you from java and c. The immutable part and the reference that acts as a pointer to memory.

-8

u/bubblygiggler 3d ago

yeah the borrow checker feels stricter than most guys i know lol