I do not agree that this is because how the compiler works. A value receiver is equivalent to pass-by-value argument, that is:
rcp.version() is equivalent to: RPC.version(rpc) thus, creating the copy of the rpc variable. So, the compiler may choose to avoid the race by not copying it, or by inlining the version function, but according to the spec, it is passed by value, i.e., it is copied. On Tue, Nov 14, 2023 at 4:16 PM burak serdar <bser...@computer.org> wrote: > > It is a data race because calling rpc.version() makes a copy of rpc, > which causes reading the field rpc.result concurrently while it is > being written by the goroutine. > > On Tue, Nov 14, 2023 at 3:59 PM Mike Schinkel <m...@newclarity.net> wrote: > > > > On Monday, November 13, 2023 at 11:28:00 PM UTC-5 Dan Kortschak wrote: > > > > https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race > > > > > > Thanks for that link. > > > > However, after studying it for well more than an hour I cannot figure out > > why it is a data race, and unfortunately Dave Cheney didn't explain it in > > his post. > > > > Robert Engels seems to be saying this isn't conceptually a data race but it > > is an unfortunate artifact of how the compiler works? > > > > -Mike > > > > -- > > 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. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/golang-nuts/241c13d1-9d9a-4028-9bce-ba856405f9edn%40googlegroups.com. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrJHvfcKVnbb8Rh1vacevkNssE1qo0vG1XTW4OVB0TEMQ%40mail.gmail.com.