Given an object obj is there a guarantee that
uintptr(unsafe.Pointer(&obj))
will always evaluate to the same value regardless of w
No absolute guarantee. Especially if Go adds compaction to its mark and sweep garbage collector.
Addresses stored in pointer types and type unsafe.Pointer will be updated, if necessary, by any garbage collector. Addresses stored in type uintptr as unsigned integers will not be updated by a garbage collector. The uintptr
type is not a pointer type, it's an integer type.
Numeric types
uintptr
an unsigned integer large enough to store the uninterpreted bits of a pointer valueconverting unsafe.Pointers to uintptr
Pointers should have been kept in unsafe.Pointers - not uintptrs - always.
Russ
For your example,
uintptr(unsafe.Pointer(&obj))
you have an unsigned integer, not an address.