This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0/5] Fix qsort comparison functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]