# Rust's Provenance APIs Let You Tell the Compiler Exactly What You Mean

Original title: Pointer Provenance in Rust vs. C++: Pointers Are Not Just Glorified Ints

> Hacker News story 50377111 · language: en · submitted 2026-11-05
> Web version: https://zeli.app/story/50377111
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 34 · by [sofiabelenlopez](<https://news.ycombinator.com/user?id=sofiabelenlopez>) · 💬 13
[original](<https://sofiabelen.github.io/projects/pointer-provenance-in-rust-vs-cpp/>) · [HN discussion](<https://news.ycombinator.com/item?id=50377111>)

## Summary

Pointer provenance is the hidden compiler bookkeeping that tracks which allocation a pointer came from, and it's why Clang can optimize away a reload of a local even when an opaque function receives a pointer. Casting a pointer to an integer in C++ exposes that provenance and forces the optimizer to give up. Rust's addr(), with_addr(), and without_provenance() let you state your intent explicitly, and Miri enforces the rules.

## Key quote

> Provenance, in short, is a hidden piece of information tracking "which allocation" a pointer originates from, which LLVM uses for optimizations.

## HN discussion (13 comments)

### [afdbcreid](<https://news.ycombinator.com/item?id=50428473>)

> Ralf Jung's series (one of the prominent developers behind Rust's memory model and author of RustBelt) about pointers is very recommended:
>
> https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html
>
> https://www.ralfj.de/blog/2020/12/14/provenance.html
>
> https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html

### [uecker](<https://news.ycombinator.com/item?id=50431630>)

> As far as I know, provenance is still a mess both on LLVM and GCC.

### [jayd16](<https://news.ycombinator.com/item?id=50428537>)

> Does C++ pointer arithmetic invalidate this post or is there some other magic there?

---

## Cite

- Page: https://zeli.app/story/50377111
- Date: 2026-11-05
- Source: sofiabelen.github.io (https://sofiabelen.github.io/projects/pointer-provenance-in-rust-vs-cpp/)
- Hacker News: https://news.ycombinator.com/item?id=50377111

## Other languages

- zh: https://zeli.app/zh/story/50377111 · markdown: https://zeli.app/zh/story/50377111.md
- ja: https://zeli.app/ja/story/50377111 · markdown: https://zeli.app/ja/story/50377111.md
- ko: https://zeli.app/ko/story/50377111 · markdown: https://zeli.app/ko/story/50377111.md
- de: https://zeli.app/de/story/50377111 · markdown: https://zeli.app/de/story/50377111.md
- es: https://zeli.app/es/story/50377111 · markdown: https://zeli.app/es/story/50377111.md
- ru: https://zeli.app/ru/story/50377111 · markdown: https://zeli.app/ru/story/50377111.md
