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 eliminate the race. If you try, you'll
see that it will behave correctly.

On Sat, Feb 11, 2017 at 8:17 AM, Dave Cheney <d...@cheney.net> wrote:

> 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.google.com/d/optout.
>

-- 
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.google.com/d/optout.

Reply via email to