4 ms·
What is the overflow behaviour here? Surely in the case of this example code, the compiler sees an overflow is going to occur, leading the variable back to zer
by londons_explore 10y ago
What is the overflow behaviour here?
Surely in the case of this example code, the compiler sees an overflow is going to occur, leading the variable back to zero.
By removing all the code, the compiler has simply combined all the additions into a single addition which overflows back to the initial value.
Seems working as intended to me.
- Dylan16807 10y agoSurely? Based on what? As far as I can see there's a very good chance it will do the same thing even if you use a saturating add.
- mook 10y agoAs far as I can tell it's just as broken if you change the Add to a Store (at least, doing that and breaking in the main routine when it's > 1 still times out on play.golang.org). That just turned into a (terrible) spinlock and has no overflow issues. On mobile, so I can't test with a real toolchain. https://play.golang.org/p/DlWBh1Via4 https://play.golang.org/p/DlWBh1Via4