I am in the process of cleaning up some of the assumptions we make in
backing slice alias detection in the gonum mat64 package.
My approach to this is to define a subset of types that we can guarantee
we will safely detect data aliasing to avoid operations clobbering input
data in unpredictable ways (important for e.g. Mul when given
a.Mul(a,b)). The subset is types that have a defined memory layout
matching the types in
github.com/gonum/blas/blas64. Then I can take
unsafe.Pointers of the relevant matrix elements to do comparisons
(requires getting 4 unsafe.Pointers). Unfortunately I then need to
convert to uintptr to perform some (small number of) math operations to
query for overlap.
I'm wondering how safe this is. Now it should be -maybe- OK because the
addresses are retained in the original value and unless there is a GC
memory move within the sequence of conversions from unsafe.Pointer to
uintptr the relative position relationships should be preserved, which
is all we care about.
Essentially, how safe is
```
a0 := uintptrAddrOf(&a.data[0])
aEnd := uintptrAddrOf(&a.data[len(a.data)-1])
b0 := uintptrAddrOf(&b.data[0])
bEnd := uintptrAddrOf(&b.data[len(b.data)-1])
```
when needing to retain spatial relationships between a and b?
@Ian, since you've expressed interest in clearing up the rules about
Go->C pointer handling (12116 and 8310) in golang-dev and this is
reasonably similar, what is your guess at this stage?
thanks
Dan