aboutsummaryrefslogtreecommitdiff
path: root/lib/libcxx/src/algorithm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcxx/src/algorithm.cpp')
-rw-r--r--lib/libcxx/src/algorithm.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libcxx/src/algorithm.cpp b/lib/libcxx/src/algorithm.cpp
index d388fee5f9..8157be6f74 100644
--- a/lib/libcxx/src/algorithm.cpp
+++ b/lib/libcxx/src/algorithm.cpp
@@ -13,6 +13,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class Comp, class RandomAccessIterator>
void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) {
+ if (first == last) // log(0) is undefined, so don't try computing the depth
+ return;
+
auto depth_limit = 2 * std::__bit_log2(static_cast<size_t>(last - first));
// Only use bitset partitioning for arithmetic types. We should also check