diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-14 12:04:57 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-14 12:04:57 +0200 |
| commit | 820dc9d76726ab9148b49630a1b4371624032918 (patch) | |
| tree | 23be73211c3f0fc58fd9b0fc37b4dc8d56ccd95f /lib/libcxx/src/algorithm.cpp | |
| parent | 958faa7031c7b50a544e151fea4d486e1c4926c1 (diff) | |
| download | zig-820dc9d76726ab9148b49630a1b4371624032918.tar.gz zig-820dc9d76726ab9148b49630a1b4371624032918.zip | |
libcxx: backport llvm/llvm-project#155476
https://github.com/llvm/llvm-project/pull/155476
Diffstat (limited to 'lib/libcxx/src/algorithm.cpp')
| -rw-r--r-- | lib/libcxx/src/algorithm.cpp | 3 |
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 |
