-
Notifications
You must be signed in to change notification settings - Fork 18k
spec: range & go: pass a pointer to an element of array leads to a different behavior with/out go #10132
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
Comments
Run the program with race detector (go build/test/run -race) |
What a shame =) Sorry for that. Thanks! |
You are passing an address to a variable to a goroutine but you let the The idiomatic way of getting the behavior you want is to create a local On Wed, Mar 11, 2015 at 7:23 AM, Anton Tyurin [email protected]
|
I met a strange behavior while passing elements of array by pointer to a function. It looks like a bug.
You can find example here:
http://play.golang.org/p/e0dDpyCYCG
This example prints
It doesn't look like an expected behavior.
Moreover this example (http://play.golang.org/p/KY4jEgtgGn) (exactly the same, but without
go
)prints
I checked it on 1.3.3, 1.4.1, 1.4.2
The text was updated successfully, but these errors were encountered: