}
func TestPtrTo(t *testing.T) {
+ // This block of code means that the ptrToThis field of the
+ // reflect data for *unsafe.Pointer is non zero, see
+ // https://golang.org/issue/19003
+ var x unsafe.Pointer
+ var y = &x
+ var z = &y
+
var i int
- typ := TypeOf(i)
+ typ := TypeOf(z)
for i = 0; i < 100; i++ {
typ = PtrTo(typ)
}
for i = 0; i < 100; i++ {
typ = typ.Elem()
}
- if typ != TypeOf(i) {
- t.Errorf("after 100 PtrTo and Elem, have %s, want %s", typ, TypeOf(i))
+ if typ != TypeOf(z) {
+ t.Errorf("after 100 PtrTo and Elem, have %s, want %s", typ, TypeOf(z))
}
}
})
}
-
type Tint int
type Tint2 = Tint
t.Errorf("Talias2 print:\nhave: %s\nwant: %s", out, want)
}
}
-
pp := *prototype
pp.str = resolveReflectName(newName(s, "", "", false))
+ pp.ptrToThis = 0
// For the type structures linked into the binary, the
// compiler provides a good hash of the string.