I know that signed overflows in C are undefined behavior according to the standard, but since in practice 2 additions for signed integers are quite often used (and even allowed, for example, using the -fwrapv option in gcc), I would like find a list of examples of programs that make good use of this fact.
Programs such as "incrementing counters that sometimes overflow" seem more suitable for unsigned integers, so I don't think they count.
Also, I do not consider compiler optimizations that might be included in this case, but useful programs that actually use signed overflows to compute something interesting.
source share