nt.Etype = 1
l = append(l, nod(OAS, s, nt))
- if types.Haspointers(l1.Type.Elem()) {
+ if l1.Type.Elem().HasHeapPointer() {
// copy(s[len(l1):], l2)
nptr1 := nod(OSLICE, s, nil)
nptr1.SetSliceBounds(nod(OLEN, l1, nil), nil, nil)
// Also works if b is a string.
//
func copyany(n *Node, init *Nodes, runtimecall bool) *Node {
- if types.Haspointers(n.Left.Type.Elem()) {
+ if n.Left.Type.Elem().HasHeapPointer() {
Curfn.Func.setWBPos(n.Pos)
fn := writebarrierfn("typedslicecopy", n.Left.Type, n.Right.Type)
return mkcall1(fn, n.Type, init, typename(n.Left.Type.Elem()), n.Left, n.Right)
var (
v1 t1
v2 t2
+
+ v1s []t1
+ v2s []t2
)
func f() {
v1 = t1{x: nil} // no barrier
v2 = t2{x: nil} // ERROR "write barrier"
}
+
+func h() {
+ // Test copies and appends.
+ copy(v1s, v1s[1:]) // no barrier
+ copy(v2s, v2s[1:]) // ERROR "write barrier"
+ _ = append(v1s, v1s...) // no barrier
+ _ = append(v2s, v2s...) // ERROR "write barrier"
+}