News for hackers. Stuff that matters.
Re:A Guide to Undefined Behavior in C and C++ (2010) by vlovich123 on Monday March 17, 2025 @01:33AM (#43385460)
> I've heard the primary reason for it is to avoid the possibility of wraparound on

Making it UB doesn’t fix that in any way that I can think of.

Re:A Guide to Undefined Behavior in C and C++ (2010) by anttihaapala on Monday March 17, 2025 @02:41AM (#43385740)
What it means is that since i as the variable is monotonically increasing, an array indexing operation that is in the loop body can be replaced with an incrementing pointer instead, which eliminates quite a lot of code. An example here: https://pvs-studio.com/en/blog/posts/cpp/0374/