As seen and explained here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83201#c13 There are strict aliasing violations: https://github.com/freebsd/freebsd/blob/master/lib/libc/stdlib/qsort.c#L64
So all the fancy swap code should be trimmed down to the byte swap, it seems.
https://reviews.freebsd.org/D15714
A commit references this bug: Author: kib Date: Sun Jun 10 17:54:44 UTC 2018 New revision: 334928 URL: https://svnweb.freebsd.org/changeset/base/334928 Log: libc qsort(3): stop aliasing. Qsort swap code aliases the sorted array elements to ints and longs in order to do swap by machine words. Unfortunately this breaks with the full code optimization, e.g. LTO. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83201 which seems to reference code directly copied from libc/stdlib/qsort.c. PR: 228780 Reported by: mliska@suse.cz Reviewed by: brooks Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D15714 Changes: head/lib/libc/stdlib/qsort.c
So can this PR be closed now?
A commit references this bug: Author: kib Date: Sun Jun 24 13:26:31 UTC 2018 New revision: 335603 URL: https://svnweb.freebsd.org/changeset/base/335603 Log: MFC r334928: libc qsort(3): stop aliasing. PR: 228780 Changes: _U stable/11/ stable/11/lib/libc/stdlib/qsort.c