-
Couldn't load subscription status.
- Fork 558
Open
Description
let x = 42;
let z = &x as *const _ as u8;As @rkruppe pointed out, this snippet casts a pointer to an int in which the pointer does not fit. AFAICT, the behavior of this operation is not guaranteed anywhere - I suppose it does a truncation. We should document what it does.
I personally would probably prefer if it was at least a warning that suggests people to write as X as u8 instead, where X is a type in which the pointer precisely fits, e.g., usize and/or u{target_pointer_width} (e.g. u64) - if that is what that cast actually happens to mean, but this is an issue that should be better discussed in rust-lang/rust, once we know what that cast means.
Metadata
Metadata
Assignees
Labels
No labels