Unstable build/host qsorts causing differing generated target code

Alexander Monakov amonakov@ispras.ru
Fri Jan 12 19:37:00 GMT 2018


On Fri, 12 Jan 2018, Jakub Jelinek wrote:
> The qsort checking failures are tracked in http://gcc.gnu.org/PR82407
> meta bug, 8 bugs in there are fixed, 2 known ones remain.

Note that qsort_chk only catches really bad issues where the compiler
invokes undefined behavior by passing an invalid comparator to qsort;
differences between Glibc and musl-hosted compilers may remain because
qsort is not quaranteed to be a stable sort: when sorting an array {A, B} where
A and B are not bitwise-identical but cmp(A, B) returns 0, the implementation of
qsort may yield either {B, A} or {A, B}, and that may cause codegen differences.

(in other words, bootstrapping on a libc with randomized qsort has
a good chance to run into bootstrap miscompares even if qsort_chk-clean)

Alexander



More information about the Gcc mailing list