3 ms·
Programs that use subtraction to implement comparisons have two different kinds of UB - the integer overflow, and the invalid argument (nontransitive function)
by o11c 3y ago
Programs that use subtraction to implement comparisons have two different kinds of UB - the integer overflow, and the invalid argument (nontransitive function) to qsort.
It's possible to implement a nontransitive function without the first UB though.
Note however that the UB only actually happens if the dynamically-passed values are more than INT_MAX apart. So e.g. if the values are never negative in practice, or limited to a small maximum, there is no UB.