Function core::ptr::without_provenance_mut
const: 1.61.0 · source · pub const fn without_provenance_mut<T>(addr: usize) -> *mut T
🔬This is a nightly-only experimental API. (
strict_provenance
#95228)Expand description
Creates a pointer with the given address and no provenance.
This is equivalent to ptr::null_mut().with_addr(addr)
.
Without provenance, this pointer is not associated with any actual allocation. Such a
no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers are
little more than a usize
address in disguise.
This is different from addr as *mut T
, which creates a pointer that picks up a previously
exposed provenance. See with_exposed_provenance_mut
for more details on that operation.
This API and its claimed semantics are part of the Strict Provenance experiment, see the module documentation for details.