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

increment operation returns wrong result #21722

Closed
janardhan1993 opened this issue Sep 1, 2017 · 3 comments
Closed

increment operation returns wrong result #21722

janardhan1993 opened this issue Sep 1, 2017 · 3 comments

Comments

@janardhan1993
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8 linux/amd64

Does this issue reproduce with the latest release?

No

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/janardhan/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build483155133=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

https://play.golang.org/p/ac24AwKKTs

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

Count should get incremented by 1

What did you see instead?

It gets incremented by 2

@davecheney
Copy link
Contributor

Your program could print 1 or 2. This is not a bug in Go so I am going to close this ticket.

We don't the issue tracker to ask questions. Please see https://golang.org/wiki/Questions for good places to ask. Thanks.

@janardhan1993
Copy link
Author

@davecheney: But count gets incremented by 2 every time. I see 2,4,6,8,10. Isn't it a bug in go. From 1.8.1 i see 1,2,3,4,5

@dominikh
Copy link
Member

dominikh commented Sep 1, 2017

It can't, but this is a bug in an old version of Go, that was fixed in Go 1.8.1.

@golang golang locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants