]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] 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)
committerMichael Pratt <mpratt@google.com>
Fri, 9 Dec 2022 20:56:57 +0000 (20:56 +0000)
commitdf5d4d3daab7e022335c0f3304d7b750bdd731a0
tree55552617fb140fbd9d855c3593133a14f159dd90
parent741e65d2bd02011fa8ba81e13f0f3d3df4f4f087
[release-branch.go1.19] 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.

For #56638.
Fixes #57124.

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>
(cherry picked from commit b14cf3d93ae5c477dd35f13f6ba41044f01a7f7d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/452438
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/sync/atomic/atomic_test.go
src/sync/atomic/type.go