Debian Codegraph @

staticcheck/sa1027/testdata/go1.0/CheckAtomicAlignment/atomic32.go

raw
1 // +build 386 arm armbe mips mipsle ppc s390 sparc riscv
2
3 package pkg
4
5 import "sync/atomic"
6
7 type T struct {
8 A int64
9 B int32
10 C int64
11 }
12
13 func fn() {
14 var v T
15 atomic.AddInt64(&v.A, 0)
16 atomic.AddInt64(&v.C, 0) //@ diag(`address of non 64-bit aligned field C passed to sync/atomic.AddInt64`)
17 atomic.LoadInt64(&v.C) //@ diag(`address of non 64-bit aligned field C passed to sync/atomic.LoadInt64`)
18 }
19
20 func fn2(t *T) {
21 addr := &t.C
22 if true {
23 atomic.LoadInt64(addr) //@ diag(`address of non 64-bit`)
24 } else {
25 _ = addr
26 }
27 }