You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's only observable if we have another goroutine watching that variable (*p). But for another goroutine to see the actual variable, Go requires some communication between the goroutines (sync or channel send). So it might be permissible to do nothing.
Agreed with @griesemer that the Go spec + memory model allow this optimization. The loop never terminates and doesn't have any synchronization events, so there's no way for another goroutine to guarantee any of the *p = i assignments have happened.
With SSA, this compiles to:
There are no reads of memory in the loop, so the entire store chain gets optimized away.
Is this a problem? I'm not sure. It is unexpected (at least, to me) so it may be worth fixing. Opinions? @rsc @josharian @griesemer @mdempsky @dr2chase @ianlancetaylor
This issue may prevent the optimization described in #15631 (treating calls just like stores). We definitely don't want calls vanishing.
The text was updated successfully, but these errors were encountered: