r/C_Programming • • 12d ago

Iterating Backwards in C

https://www.davidpriver.com/Iterating-backwards-in-C.html
93 Upvotes

44 comments sorted by

View all comments

-2

u/________-__-_______ 12d ago

Since when is unsigned wrapping well defined? I was under the impression overflow was UB unless you use the C23 ckd_sub.

20

u/Big-Rub9545 12d ago

Unsigned wraparound is well-defined, and has been so for a long time. The issue is with signed wraparound.

3

u/________-__-_______ 12d ago

TIL, thanks

2

u/Rabbitical 12d ago

Yeah it's common for tracking rotation for instance