@@ -42,6 +42,19 @@ pub trait SimdConstPtr: Copy + Sealed {
42
42
/// Equivalent to calling [`pointer::addr`] on each element.
43
43
fn addr ( self ) -> Self :: Usize ;
44
44
45
+ /// Convert an address to a pointer without giving it any provenance.
46
+ ///
47
+ /// Without provenance, this pointer is not associated with any actual allocation. Such a
48
+ /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
49
+ /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers
50
+ /// are little more than a usize address in disguise.
51
+ ///
52
+ /// This is different from [`Self::from_exposed_addr`], which creates a pointer that picks up a
53
+ /// previously exposed provenance.
54
+ ///
55
+ /// Equivalent to calling [`core::ptr::without_provenance`] on each element.
56
+ fn without_provenance ( addr : Self :: Usize ) -> Self ;
57
+
45
58
/// Creates a new pointer with the given address.
46
59
///
47
60
/// This performs the same operation as a cast, but copies the *address-space* and
@@ -118,6 +131,14 @@ where
118
131
unsafe { core:: mem:: transmute_copy ( & self ) }
119
132
}
120
133
134
+ #[ inline]
135
+ fn without_provenance ( addr : Self :: Usize ) -> Self {
136
+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
137
+ // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any
138
+ // provenance).
139
+ unsafe { core:: mem:: transmute_copy ( & addr) }
140
+ }
141
+
121
142
#[ inline]
122
143
fn with_addr ( self , addr : Self :: Usize ) -> Self {
123
144
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
0 commit comments