Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: atomic mistakes check seems confused about scope #15118

cespare opened this issue Apr 4, 2016 · 1 comment

cmd/vet: atomic mistakes check seems confused about scope #15118

cespare opened this issue Apr 4, 2016 · 1 comment


Copy link

@cespare cespare commented Apr 4, 2016

What version of Go are you using (go version)?

go 1.6

What operating system and processor architecture are you using (go env)?


What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on is best.

Consider a program like the following ( link):

package main

import (

func main() {
    var c int64
    for i := 0; i < 10; i++ {
        go func() {
            for {
                c := atomic.AddInt64(&c, 1)
                if c%10000000 == 0 {
    select {}

What did you expect to see?

Since the c in the inner function is a different c from the outer atomic counter, I expected vet to not complain.

What did you see instead?

go vet gives the following output:

test.go:13: direct assignment to atomic value

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Apr 5, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in 0d37538 Apr 6, 2016
@golang golang locked and limited conversation to collaborators Apr 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.