aboutsummaryrefslogtreecommitdiff
path: root/lib/libcxx/src/algorithm.cpp
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-10-15 00:24:35 +0200
committerGitHub <noreply@github.com>2025-10-15 00:24:35 +0200
commit27a396db4fd2e9734dab63d203fb354084e2c237 (patch)
tree998fe71c701da161fc7726694644532fa4d577dc /lib/libcxx/src/algorithm.cpp
parent4edebf40d53c7e69afd088c9967f13ab8aafe1fd (diff)
parentbc58b5dc53cce066d224925ce8fb4bb79665a1d1 (diff)
downloadzig-27a396db4fd2e9734dab63d203fb354084e2c237.tar.gz
zig-27a396db4fd2e9734dab63d203fb354084e2c237.zip
Merge pull request #25572 from alexrp/libcxx-backports
`libcxx`: backport llvm/llvm-project#155476, llvm/llvm-project#147389, llvm/llvm-project#155786
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