]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: skip "_" function in reflectdata.MarkUsedIfaceMethod
authorCuong Manh Le <cuong@orijtech.com>
Sun, 18 Apr 2021 19:39:50 +0000 (02:39 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 19 Apr 2021 04:37:32 +0000 (04:37 +0000)
commita72622d028077643169dc48c90271a82021f0534
tree54362cfefeb1c190aea7ce205e5883f7b78d214c
parentc914e6160db8b6af358cad90ed7272ebc5c22dda
cmd/compile: skip "_" function in reflectdata.MarkUsedIfaceMethod

CL 256798 added compiler ability to retain only used interface methods,
by generating a mark relocation whenever an interface method is used. To
do that, the compiler needs the current function linker object.

However, for unnamed function "func _()", its linker object is nil,
causes the compiler crashes for code in #45258.

CL 283313 fixed the code in #45258 unintentionally, since when the
compiler now does not walk unnamed functions anymore.

This CL fixes the root issue, by making reflectdata.MarkUsedIfaceMethod
skips unnamed functions, and also adding regression test.

Fixes #45258

Change-Id: I4cbefb0a89d9928f70c00dc8a271cb61cd20a49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/311130
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/reflectdata/reflect.go
test/fixedbugs/issue45258.go [new file with mode: 0644]