1
0
mirror of https://github.com/golang/go synced 2024-09-25 05:10:12 -06:00

reflect: initialize ptrdata earlier in StructOf

It needs to be set before addTypeBits is called.

Fixes #31043

Change-Id: I692b4047dc17bd68202d45da41dd55d432383e59
Reviewed-on: https://go-review.googlesource.com/c/go/+/169318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Keith Randall 2019-03-25 20:29:18 -07:00 committed by Keith Randall
parent 17f888c5a8
commit b7b7b4d6d4

View File

@ -2639,6 +2639,7 @@ func StructOf(fields []StructField) Type {
typ.tflag = 0 typ.tflag = 0
typ.hash = hash typ.hash = hash
typ.size = size typ.size = size
typ.ptrdata = typeptrdata(typ.common())
typ.align = typalign typ.align = typalign
typ.fieldAlign = typalign typ.fieldAlign = typalign
typ.ptrToThis = 0 typ.ptrToThis = 0
@ -2709,7 +2710,6 @@ func StructOf(fields []StructField) Type {
typ.gcdata = &bv.data[0] typ.gcdata = &bv.data[0]
} }
} }
typ.ptrdata = typeptrdata(typ.common())
typ.alg = new(typeAlg) typ.alg = new(typeAlg)
if hashable { if hashable {
typ.alg.hash = func(p unsafe.Pointer, seed uintptr) uintptr { typ.alg.hash = func(p unsafe.Pointer, seed uintptr) uintptr {