]> Cypherpunks repositories - gostls13.git/commit
sync/atomic: allow linked list of atomic pointers again
authorRuss Cox <rsc@golang.org>
Tue, 15 Nov 2022 14:54:39 +0000 (09:54 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 15 Nov 2022 18:14:39 +0000 (18:14 +0000)
commitb14cf3d93ae5c477dd35f13f6ba41044f01a7f7d
treedb7a421a387b59923ef3f6f0412809007bcf6492
parent56d18207823d6e1c18ca46409180c40ae800230c
sync/atomic: allow linked list of atomic pointers again

For #56603, CL 448275 added a _ [0]T field to atomic.Pointer,
so that different kinds of atomic.Pointer are not convertible.

Unfortunately, that breaks code like:

type List struct {
Next atomic.Pointer[List]
}

which should be valid, just as using Next *List is valid.
Instead, we get:

./atomic_test.go:2533:6: invalid recursive type List
./atomic_test.go:2533:6: List refers to
./atomic_test.go:2534:13: "sync/atomic".Pointer refers to
./atomic_test.go:2533:6: List

Fix by using _[0]*T instead.

Change-Id: Icc4c83c691d35961d20cb14b824223d6c779ac5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/450655
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/sync/atomic/atomic_test.go
src/sync/atomic/type.go