News for hackers. Stuff that matters.
Re:Out-of-bounds read and write in the glibc's qsort() by mac3n on Monday February 05, 2024 @03:00PM (#39266283)
Does that mean all programs which use qsort have "Undefined Behavior"™? Just those which use nontransitive comparison functions? Only those which encounter non-transitivity?
Re:Out-of-bounds read and write in the glibc's qsort() by o11c on Monday February 05, 2024 @04:54PM (#39267772)
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.