Re:Cmd/compile: Go 1.8 regression: sync/atomic loop elided
by 010a on Monday February 20, 2017 @10:28AM
(#13688036)
> It's an infinite loop ...
In Go, if runtime.GOMAXPROCS() returns 1 or is set to 1 (meaning, Go only has access to a single system thread), the 'for' loop canabalizes the scheduler and the goroutine is rarely or never scheduled.
That fact doesn't make the OP's statement true, or have anything to do with the optimization bug, but it is worth pointing out that there are situations where Go correctly cannot guarantee that goroutine is executed.
Re:Cmd/compile: Go 1.8 regression: sync/atomic loop elided
by eternalban on Monday February 20, 2017 @10:53AM
(#13688241)
Yes, I am aware of that. Just addressing the OP's misread of the code.
But do note that /may/ change given the GC considerations:
This is a pointer:
> Because sync.Wait() isn't used, there's no guarantee the goroutine will execute at all before program halt.It's an infinite loop ...
> I'm not sure why atomic.Add* should get special treatment though
Because it side effects and arguably it is a form (mem) I/O in context of modern systems.