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/include/__algorithm/sort.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/libcxx/include/__algorithm') diff --git a/lib/libcxx/include/__algorithm/sort.h b/lib/libcxx/include/__algorithm/sort.h index 06cb5b8ce7..8aa894e922 100644 --- a/lib/libcxx/include/__algorithm/sort.h +++ b/lib/libcxx/include/__algorithm/sort.h @@ -860,6 +860,9 @@ __sort<__less&, long double*>(long double*, long double*, __less _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { + if (__first == __last) // log(0) is undefined, so don't try computing the depth + return; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __depth_limit = 2 * std::__bit_log2(std::__to_unsigned_like(__last - __first)); -- cgit v1.2.3