infinite loop
infinite loop
Posted Jul 19, 2024 16:24 UTC (Fri) by xorbe (guest, #3165)Parent article: New features in C++26
The "infinite loop as UB" was a step too far, imho. If I tell you to spin, then spin. Not for the compiler to decide if that's what I wanted to do or not. I am also not on board with loops that increment an integer from positive to negative being UB (ironically, promoted to an infinite loop). I can put anything in the last field of the for-statement, and it doesn't have to be ++/--, I could do x = (-x + (x > 0 ? -1 : 1)), and it will bounce all over the place. If I asked for signed 0x7FFF_FFFF to roll over to 0x8000_0000 then DO IT. If you want to optimize my loop code, then give me some other new syntax to indicate that I want an unrolled optimized loop that moves linearly.