External Publication
Visit Post

Idea / Pre-RFC: Treat 0x0 as a valid address, not as null

Rust Internals [Unofficial] February 17, 2026
Source

RalfJung:

I will also note that framing this as "demands" makes the entire thing sound needlessly confrontational

A tangent on this topic: I imagine this is probably a non-native English problem. In French, for instance, the verb demander is a "false-ish friend", as it means to ask or to request[1].

But it's nonetheless good for you to have called out that the usage of that verb ought to be adjusted/edited (cc @H4n_uL, we understand you probably did not intend it as confrontational ).


H4n_uL:

197g:

there be a library pointer (NonNull but with lifetime) that encapsulates at least the safety preconditions of read_volatile with which we have an alternative to represent values that start at address 0.

This is a much more practical path than what I originally proposed. A vocabulary type in core that builds on the existing read_volatile safety model without breaking changes to &T nor niche disruption, and the ecosystem adopts it at its own pace. I love it.

  • (Emphases mine.)

Ever since I started reading the OP, this was my thought as well; it feels like the main culprit here is the following:

Working with direct, raw, volatile_{read,write}()s is unergonomic / impractical / unpleasant.

But for such cases, there is always a solution for this, one which need not involve a language change : to define a convenience library abstraction (hence my first emphasis in that quote).

From there, stems a second important question:

Should such a library abstraction live in the standard library (notably: ::core[2]), or could it just be a user-provided "third-party" library?

Given that the use case for null-supporting pointer operations remains, in the overall ecosystem of Rust usage so far, incredibly niche[3], I'd personally vote for starting with the latter, and seeing how it goes from there.

I'd like to point out, in this regard, that the following two crates exist:

docs.rs

volatile - Rust

Provides volatile wrapper types for raw pointers.

docs.rs

voladdress - Rust

A crate for working with volatile locations, particularly Memory Mapped IO (MMIO).

So we'd have to sort out:

  • whether your ergonomic requirements are satisfied by one of these crates;
  • or if they're not, in which regard? Where could these crates be improved (cc @phil_opp, the author of the former, and @Lokathor, of the latter).
    • Notably, ::voladdress has no lifetimes in its types, and whilst ::volatile does have a lifetime-infected wrapper, VolatileRef<'lt>, it uses a ptr::NonNull, so it won't be usable out-of-the-box for the OP's situation.

You may thus want to write (or kindly ask that somebody else write for you) your own take on the matter. Whilst it may seem "excessive" —"why does Rust not come pre-bundled with such a tool?"—, I'd like to point out that the energy and time required for authoring such a thing is most likely smaller than the overall energy and time spent in this whole very thread


  1. the translation of "to demand" in French then being exiger. ↩︎

  2. hence my second emphasis ↩︎

  3. heh ↩︎

Discussion in the ATmosphere

Loading comments...