Closed
Description
Hi,
Read quite a lot of the information out there and I still have a bunch of open questions about pointers, answering them will help me but I also think that it will be good to add to the docs for other people.
This list isn't exhaustive and I'll try to add stuff I see and don't know the answer to:
- Passing a pointer to a
const
variable. -> Is fine but may result in different pointers to the same variable (See Some questions around what is UB and what is defined when using raw pointers #205 (comment)) - Mutating a
const
variable through raw pointer casting. -> Not allowed. (See Some questions around what is UB and what is defined when using raw pointers #205 (comment)) - Casting a pointer to
usize
and back. - Checking alignment via modulo over
ptr as usize
. (related to 3) (less relevant now that we have align_offset but people still do it in the wild).