diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/qsort.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/qsort.cpp new file mode 100644 index 0000000000000..f2b90c47a3d5c --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/qsort.cpp @@ -0,0 +1,24 @@ +// RUN: %clangxx -O2 %s -o %t + +#include +#include +#include +#include +#include + +static int compare_ints(const void *a, const void *b) { + return *(const int *)b - *(const int *)a; +} + +int main() { + std::vector nums(100000); + for (auto &n : nums) + n = rand(); + + std::vector to_qsort = nums; + qsort(to_qsort.data(), to_qsort.size(), sizeof(to_qsort[0]), &compare_ints); + + std::sort(nums.begin(), nums.end()); + + assert(nums == to_qsort); +}