From 820dc9d76726ab9148b49630a1b4371624032918 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Tue, 14 Oct 2025 12:04:57 +0200 Subject: libcxx: backport llvm/llvm-project#155476 https://github.com/llvm/llvm-project/pull/155476 --- lib/libcxx/src/algorithm.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/libcxx/src/algorithm.cpp') 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 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(last - first)); // Only use bitset partitioning for arithmetic types. We should also check -- cgit v1.2.3