]> Cypherpunks repositories - gostls13.git/commit
reflect: handle zero-sized fields of directly-stored structures correctly
authorKeith Randall <khr@golang.org>
Thu, 7 Aug 2025 22:30:54 +0000 (15:30 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 8 Aug 2025 13:51:37 +0000 (06:51 -0700)
commitb3388569a187ea6be48caa41265f2b4dbc2fdfd3
treeb4c1a95ca94f80fc817637399c36557bcc31b073
parentd83b16fcb8de765f25cabbea63284406ea6dd091
reflect: handle zero-sized fields of directly-stored structures correctly

type W struct {
E struct{}
X *byte
}

type W is a "direct" type. That is, it is a pointer-ish type that can
be stored directly as the second word of an interface.

But if we ask reflect for W's first field, that value must *not* be
direct, as zero-sized things cannot be stored directly.

This was a problem introduced in CL 681937. Before that, types like W
were not eligible for directness.

Fixes #74935

Change-Id: Idefb55c23eaa59153009f863bad611593981e5cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/694195
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/reflect/value.go
test/fixedbugs/issue74935.go [new file with mode: 0644]