]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix wrong unsafe.Offsetof evaluation inside generic function
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 30 May 2022 14:34:01 +0000 (21:34 +0700)
committerKeith Randall <khr@golang.org>
Tue, 31 May 2022 14:58:09 +0000 (14:58 +0000)
commit085529bd5fa3ab508784f6a3d42f15d2dafddc65
treeef631824e361c8a78bdcb4cb6487c6a88b55bcb1
parentcfd202c701d3c1fda740a8c3c725fbb704054591
cmd/compile: fix wrong unsafe.Offsetof evaluation inside generic function

For instantiated generic functions, all implicit dot operations are
resolved. Thus unsafe.Offsetof may calculating the offset against the
wrong base selector.

To fix it, we must remove any implicit dot operations to find the first
non-implicit one, which is the right base selector for calculating the
offset.

Fixes #53137

Change-Id: I38504067ce0f274615b306edc8f7d7933bdb631a
Reviewed-on: https://go-review.googlesource.com/c/go/+/409355
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/typecheck/const.go
test/fixedbugs/issue53137.go [new file with mode: 0644]