Skip to content

Commit fea7c43

Browse files
committed
sync/atomic: clarify 64-bit alignment bug
Local variables can also be relied on the be 64-bit aligned, since they will be escaped to the heap if used with any atomic operations. Also, allocated arrays are also aligned, just like structs and slices. Fixes #18955. Change-Id: I8a1897f6ff78922c8bfcf20d6eb4bcb17a70ba2d Reviewed-on: https://go-review.googlesource.com/48112 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 58ae050 commit fea7c43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sync/atomic/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ import (
4848
// On non-Linux ARM, the 64-bit functions use instructions unavailable before the ARMv6k core.
4949
//
5050
// On both ARM and x86-32, it is the caller's responsibility to arrange for 64-bit
51-
// alignment of 64-bit words accessed atomically. The first word in a global
52-
// variable or in an allocated struct or slice can be relied upon to be
51+
// alignment of 64-bit words accessed atomically. The first word in a
52+
// variable or in an allocated struct, array, or slice can be relied upon to be
5353
// 64-bit aligned.
5454

5555
// SwapInt32 atomically stores new into *addr and returns the previous *addr value.

0 commit comments

Comments
 (0)