*T
ptr RS-E1028Transmuting a literal to pointer is undefined behavior.
For the cases where it is required to construct a null
ptr,
Rust provides the std::ptr::null()
and std::ptr::null_mut()
methods instead.
Note:
Not all cases can be detected at the moment of this writing. For example, variables which hold a null pointer and are then fed to a transmute call aren't detectable yet.
fn foo() {
let null_ref: &u64 = unsafe { std::mem::transmute(0 as *const u64) };
}