[libcxx-commits] [libcxx] [libc++] Fix broken precondition of __bit_log2 (PR #155476)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 26 12:56:14 PDT 2025


================
@@ -860,6 +860,9 @@ __sort<__less<long double>&, long double*>(long double*, long double*, __less<lo
 template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
+  if (__first == __last) // don't even try computing the depth
----------------
var-const wrote:

How about 
```
`log(0)` is undefined, so don't try computing the depth
```
?

https://github.com/llvm/llvm-project/pull/155476


More information about the libcxx-commits mailing list