]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.18] cmd/compile: fix wrong unsafe.Offsetof evaluation inside...
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 30 May 2022 14:34:01 +0000 (21:34 +0700)
committerHeschi Kreinick <heschi@google.com>
Wed, 6 Jul 2022 19:31:10 +0000 (19:31 +0000)
commit3da88c0bdc94f8cacc5cef3026a7e256109e616d
treef904550973079686da32c6b5b25a4f1235f4d39f
parentf0eca661ea69b107143c9619ec0d0df4829b5b7e
[release-branch.go1.18] 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 #53159

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>
Reviewed-on: https://go-review.googlesource.com/c/go/+/409494
src/cmd/compile/internal/typecheck/const.go
test/fixedbugs/issue53137.dir/main.go [new file with mode: 0644]
test/fixedbugs/issue53137.go [new file with mode: 0644]