|
|
|
|
|
by porges
3993 days ago
|
|
The point here is not particularly about signedness, it's that UB allows better optimizations to be performed. If overflow is defined to wrap around then it's potentially an infinite loop (take N == MAXVALUE). With overflow defined as UB you can say the loop executes exactly N times (because you're not allowed to write code that overflows). So UB is both bad and a source of power :) |
|
But in the case of C, that is what it is about since unsigned integers have defined behavior, so you can only have UB and the optimizations when you use a signed integer.