4 ms·
> Find me one system in current use (2020) that isn't 2's complement. Fortunately, C2x will stop with the meme assumption that two's complement hasn't taken ov
by beefhash 7y ago
> Find me one system in current use (2020) that isn't 2's complement.
Fortunately, C2x will stop with the meme assumption that two's complement hasn't taken over the world (see draft N2479). It will not, however, specify signed integer overflow, which remains UB. :^)
- loup-vaillant 7y agoCompiler writers are too hooked on loop optimisations now to give up on undefined signed overflow. I'm afraid the only clean fix is to augment the language with an actual `for` loop, with an immutable loop index and well defined start and finish values. Stuff like: for (size_t i : 0..10) {} // Will go from 0 to 9 included. for (size_t i : 10..0, -1) {} // Will go from 10 to 1 included... // ...or maybe from 9 to 0 included? // Not sure which is best.