On Fri, Jun 4, 2021 at 3:02 PM christoph...@gmail.com
<christophe.mees...@gmail.com> wrote:

> > That is true in current implementations, but Go, the language, does not 
> > guarantee that pointers will never move.
>
> That is what I thought, but it is allowed to use a pointer far map keys. And 
> I have seen some programs/package using this feature.
> Apparently all these programs and packages would break if objects were to be 
> moved around ?

u-int-ptr is just an Unsigned Integer the size of a Pointer. Nothing
conceptually different wrt to int, uint, int64, ...

It has no special properties wrt to pointers. Unsafe conversion
from/to uintptr and unsafe.Pointers is supported, yes, but as soon as
the value of the pointer becomes an uintptr, the connection is lost.
Sometimes the disconnection does not matter because the pointer is
known to be stable. Like the address of C-malloced memory, or C-mmaped
memory etc. However, Go pointers to Go objects allocated by the Go
runtime can move and _do_ move in ways that are not specified. So
correct code cannot rely on such stability.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-WUGVSfCV3UB4dEekFLQozEvsrXu29bWpfQhHbsOwUUog%40mail.gmail.com.

Reply via email to