Source file
test/fixedbugs/issue16985.go
1
2
3
4
5
6
7
8
9 package main
10
11 import "sync/atomic"
12
13 var count uint32
14
15 func main() {
16 buffer := []byte("T")
17 for i := 0; i < len(buffer); {
18 atomic.AddUint32(&count, 1)
19 _ = buffer[i]
20 i++
21 i++
22 }
23
24 for i := 0; i < len(buffer); {
25 atomic.CompareAndSwapUint32(&count, 0, 1)
26 _ = buffer[i]
27 i++
28 i++
29 }
30
31 for i := 0; i < len(buffer); {
32 atomic.SwapUint32(&count, 1)
33 _ = buffer[i]
34 i++
35 i++
36 }
37 }
38
View as plain text