-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
compile: add result in the infinite loop is wrong #45826
Comments
A program with a data race in it is not a valid Go program and it could do anything. In this case, it look like the compiler decided that it is allowed to remove the writes to |
In fact, it can be reproduced like this. Is this also considered to be a race?
|
@WangLeonard you may be interetested in https://blog.golang.org/race-detector Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
Anything that when run under |
|
If you are really interested in understanding the underlying formalism that explains what a race is in Go, see https://golang.org/ref/mem. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I know this example may not be appropriate, there is a data rece
But it always prints 0
go build -gcflags="-N -l -S -m=2" ./main.go
In the assembly code of go func,
It's just jmp, but no add.
I add some extra code to go func, such as print, or modifying it to atomic, it will not print 0 anymore.
What did you expect to see?
not 0
What did you see instead?
0
The text was updated successfully, but these errors were encountered: