This libgo patch corrects the runtime structfield type to match the reflect type, which is the one actually generated by the compiler. The offset field in structfield has changed to offsetAnon, and now requires a shift to get the actual offset value. This fixes https://golang.org/issue/23391. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 257393) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -c02c71187c9794b50444e2858c582e66a3442ee8 +1927b40e59e7c2067ecb03384b331d1be3cb5eea The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/cgocall.go =================================================================== --- libgo/go/runtime/cgocall.go (revision 257357) +++ libgo/go/runtime/cgocall.go (working copy) @@ -189,7 +189,7 @@ func cgoCheckArg(t *_type, p unsafe.Poin return } for _, f := range st.fields { - cgoCheckArg(f.typ, add(p, f.offset), true, top, msg) + cgoCheckArg(f.typ, add(p, f.offset()), true, top, msg) } case kindPtr, kindUnsafePointer: if indir { Index: libgo/go/runtime/type.go =================================================================== --- libgo/go/runtime/type.go (revision 257357) +++ libgo/go/runtime/type.go (working copy) @@ -113,11 +113,19 @@ type ptrtype struct { } type structfield struct { - name *string // nil for embedded fields - pkgPath *string // nil for exported Names; otherwise import path - typ *_type // type of field - tag *string // nil if no tag - offset uintptr // byte offset of field within struct + name *string // nil for embedded fields + pkgPath *string // nil for exported Names; otherwise import path + typ *_type // type of field + tag *string // nil if no tag + offsetAnon uintptr // byte offset of field<<1 | isAnonymous +} + +func (f *structfield) offset() uintptr { + return f.offsetAnon >> 1 +} + +func (f *structfield) anon() bool { + return f.offsetAnon&1 != 0 } type structtype struct {