Source file
test/fixedbugs/issue24449.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "sync/atomic"
11 )
12
13 var cnt32 int32
14
15
16 func test32(a, b []int) bool {
17
18
19
20 atomic.AddInt32(&cnt32, 1)
21 if len(a) == len(b) {
22 atomic.AddInt32(&cnt32, 2)
23 }
24 atomic.AddInt32(&cnt32, 4)
25 if len(a) >= len(b) {
26 atomic.AddInt32(&cnt32, 8)
27 }
28 if len(a) <= len(b) {
29 atomic.AddInt32(&cnt32, 16)
30 }
31 return atomic.LoadInt32(&cnt32) == 31
32 }
33
34 var cnt64 int64
35
36
37 func test64(a, b []int) bool {
38
39
40
41 atomic.AddInt64(&cnt64, 1)
42 if len(a) == len(b) {
43 atomic.AddInt64(&cnt64, 2)
44 }
45 atomic.AddInt64(&cnt64, 4)
46 if len(a) >= len(b) {
47 atomic.AddInt64(&cnt64, 8)
48 }
49 if len(a) <= len(b) {
50 atomic.AddInt64(&cnt64, 16)
51 }
52 return atomic.LoadInt64(&cnt64) == 31
53 }
54
55 func main() {
56 if !test32([]int{}, []int{}) {
57 panic("test32")
58 }
59 if !test64([]int{}, []int{}) {
60 panic("test64")
61 }
62 }
63
View as plain text