Normally, when moving Go values of type T from one location to another,
we don't need to worry about partial overlaps. The two Ts must either be
in disjoint (nonoverlapping) memory or in exactly the same location.
There are 2 cases where this isn't true:
1) Using unsafe you can arrange partial overlaps.
2) Since Go 1.17, you can use a cast from a slice to a ptr-to-array.
This feature can be used to construct partial overlaps of array types.
var a int
p := (*int)(a[:])
q := (*int)(a[1:])
*p = *q
We don't care about solving 1. Or at least, we haven't historically
and no one has complained.
For 2, we need to ensure that if there might be partial overlap,
then we can't use OpMove; we must use memmove instead.
(memmove handles partial overlap by copying in the correct
direction. OpMove does not.)
Note that we have to be careful here not to introduce a call when
we're marshaling arguments to a call or unmarshaling results from a call.
Reviewed-by: David Chase <firstname.lastname@example.org>
Reviewed-by: Matthew Dempsky <email@example.com>
TryBot-Result: Gopher Robot <firstname.lastname@example.org>
Run-TryBot: Keith Randall <email@example.com>
(cherry picked from commit 332a598)