Just to add, it is ok to have a pointer (unsafe.Pointer or otherwise) to
unreadable memory. For instance, you can use syscall.Mmap and
syscall.Mprotect to produce such a state. The GC will not dereference any
pointer that points outside the Go heap.
Public Service Announcement #1: Don't use sy
It seems to me the only way to achieve this would be to allocate a []byte
twice the size you need, to be sure, then get the address of the start and
offset it (if necessary) until it is a number (as in uintptr) divisible by
16, then it would be correctly structured. I would think you will find t
On Tuesday, August 21, 2018 at 7:08:43 PM UTC-4, Carl Mastrangelo wrote:
>
> The answer must be more nuanced than that, because it is possible to take
> a nil pointer and construct an unsafe.Pointer from it.
>
> The reason I am interested in this is (and please don't judge too early)
> is I'm t
On Tuesday, August 21, 2018 at 7:08:43 PM UTC-4, Carl Mastrangelo wrote:
>
>
> The reason I am interested in this is (and please don't judge too early)
> is I'm toying around with implementing some atomic primitives. In
> particular, I would like to play around with with the cmpxchg16b
> instru
On Tue, Aug 21, 2018 at 4:08 PM, 'Carl Mastrangelo' via golang-nuts
wrote:
>
> The answer must be more nuanced than that, because it is possible to take a
> nil pointer and construct an unsafe.Pointer from it.
Yes, OK, nil is an exception, as it is for any pointer type.
> The reason I am intere
The answer must be more nuanced than that, because it is possible to take a
nil pointer and construct an unsafe.Pointer from it.
The reason I am interested in this is (and please don't judge too early) is
I'm toying around with implementing some atomic primitives. In particular,
I would like
On Tue, Aug 21, 2018 at 1:19 PM, 'Carl Mastrangelo' via golang-nuts
wrote:
>
> If I create an unsafe.Pointer that points to an invalid memory address, but
> I never deference it or otherwise pass it along, what happens to it?
If you never deference it and never do anything with it, then in
practi
(to short circuit any question, I have already
read https://golang.org/pkg/unsafe/ )
If I create an unsafe.Pointer that points to an invalid memory address, but
I never deference it or otherwise pass it along, what happens to it? Is it
a valid go program to just create such a pointer? The mai