This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 0/5] Fix qsort comparison functions
- From: Yury Gribov <y dot gribov at samsung dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 17 Dec 2015 11:55:25 +0300
- Subject: [PATCH 0/5] Fix qsort comparison functions
- Authentication-results: sourceware.org; auth=none
Hi all,
This patchset fixes bugs in comparison functions used in qsort(3).
Standard requires comparison functions to satisfy certain
symmetry/transitivity axioms ("total ordering" in
http://pubs.opengroup.org/onlinepubs/009695399/functions/qsort.html).
Violation triggers undefined behavior which can e.g. cause qsort to
produce invalid results (or even crash - check
https://bugzilla.samba.org/show_bug.cgi?id=3959).
Most of the patches are pretty obvious except for no. 3 for which I was
failed to devise a behavior-preserving fix. I've Cc-ed the original
authors in hope they'll be able to help.
I've verified all patches on x86_64-pc-linux-gnu (bootstrap + regression
test).
NB: Bugs were found with SortChecker tool
(https://github.com/yugr/sortcheck).
/Yury