Open
Description
What it does
Points out potential UB when transmuting an integer into a pointer.
As of Rust 1.78, LLVM is informed that this is UB. In <= 1.77 this works, and the change caught me off guard, as an int->ptr conversion happens a lot when dealing with win32.
Advantage
The original code will cause UB if the pointer is dereferenced. The recommended code works as intended.
Drawbacks
Possible false positives, though I'm not sure of the use case.
Example
// win32 tends to hand out isize and wants you to use them as pointers
let l_param: isize = ...;
let evt: *mut MSLLHOOKSTRUCT = std::mem::transmute(l_param);
Could be written as:
let l_param: isize = ...;
let evt = l_param as *mut MSLLHOOKSTRUCT;