Debian Codegraph @

test/fixedbugs/issue16985.go

raw
1 // run
2
3 // Copyright 2016 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // issue 16985: intrinsified AMD64 atomic ops should clobber flags
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 }