3 ms·
>Note that's just dereferencing: there's nothing inherently unsafe about just creating and passing around the pointers themselves. Sure there is. Passing aroun
by silon3 13y ago
>Note that's just dereferencing: there's nothing inherently unsafe about just creating and passing around the pointers themselves.
Sure there is. Passing around multiple pointers can result in a double free and then the dangerous dereference can happen. I'm guessing the developer must be careful when writing unsafe blocks to make sure this doesn't happen.
- octo_t 13y agobut they are safe until you decide to do that deferencing, otherwise they're just uint_ptrs really.
- dbaupp 13y agoUnsafe behaviours with raw pointers: - dereferencing - arithmetic (implemented as ptr.offset(number) in the stdlib), since it is undefined behaviour for LLVM to move a pointer to point outside* of the object that it came from originally (even without deferencing) Everything else is OK. (Although the only other thing possible is passing it around as "black box" value.) *One byte past the end is ok.