From b7b7b4d6d4304758c15de940c36ab7d063249ef2 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 25 Mar 2019 20:29:18 -0700 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/reflect/type.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reflect/type.go b/src/reflect/type.go index 10509ac418..83e59014ed 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -2639,6 +2639,7 @@ func StructOf(fields []StructField) Type { typ.tflag = 0 typ.hash = hash typ.size = size + typ.ptrdata = typeptrdata(typ.common()) typ.align = typalign typ.fieldAlign = typalign typ.ptrToThis = 0 @@ -2709,7 +2710,6 @@ func StructOf(fields []StructField) Type { typ.gcdata = &bv.data[0] } } - typ.ptrdata = typeptrdata(typ.common()) typ.alg = new(typeAlg) if hashable { typ.alg.hash = func(p unsafe.Pointer, seed uintptr) uintptr {