Closed kornelski closed 7 years ago
Actually it was implement like this at one point, but appearantly it is somewhat of a UB:
https://users.rust-lang.org/t/is-this-pointer-dereference-inherently-unsafe/13428/2
Note that version I'm proposing is substantially different, because it doesn't use NULL.
But it's still a pointer to an un-allocated, unknown piece of memory. AFAICT null is not special that way.
OK
Current implementation creates a dummy object. It's possible to get alignment with just pointer manipulation.
I think
&(*ptr)
is valid and does not actually deference the object, because such construct is also allowed for non-movable values (where*obj
causes an error, but&*obj
is fine).