On Saturday, February 11, 2017 at 4:23:07 PM UTC+8, Axel Wagner wrote:
>
> To expand on Dave's point: Your function has a data race (reads/writes
> concurrent with writes in different goroutines) and thus its behavior is
> not defined. Run with the benchmark with -race to confirm. The compiler
To expand on Dave's point: Your function has a data race (reads/writes
concurrent with writes in different goroutines) and thus its behavior is
not defined. Run with the benchmark with -race to confirm. The compiler can
pretty much do, what it wants in that case.
You need to add synchronization to
It's neither, its undefined.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.goo
https://github.com/golang/go/issues/5373
I made a test
package main
import (
"testing"
)
const N = 1024 * 100
var a [N]int
func BenchmarkArrayPtr(b *testing.B) {
for i := 0; i < b.N; i++ {
for i := range &a {
a[i] = 0
}
}
}
func BenchmarkArray(b *testin