[libcxx-commits] [PATCH] D101677: [libc++] [LIBCXX-DEBUG-FIXME] Our `__debug_less` breaks some complexity guarantees.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 5 13:24:02 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG165ad89947e8: [libc++] [LIBCXX-DEBUG-FIXME] Our `__debug_less` breaks some complexity… (authored by arthur.j.odwyer).

Changed prior to commit:
  https://reviews.llvm.org/D101677?vs=342161&id=343163#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101677/new/

https://reviews.llvm.org/D101677

Files:
  libcxx/docs/DesignDocs/DebugMode.rst
  libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp


Index: libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
+++ libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: LIBCXX-DEBUG-FIXME
-
 // <algorithm>
 
 // template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
@@ -81,7 +79,9 @@
         assert(ia[0] == static_cast<int>(N)-1);
         assert(ia[N-1] == 0);
         assert(std::is_sorted(ia, ia+N, std::greater<value_type>()));
+#ifndef _LIBCPP_DEBUG
         assert(pred.count() <= (N-1));
+#endif
     }
     delete [] ia;
 }
Index: libcxx/docs/DesignDocs/DebugMode.rst
===================================================================
--- libcxx/docs/DesignDocs/DebugMode.rst
+++ libcxx/docs/DesignDocs/DebugMode.rst
@@ -70,6 +70,12 @@
 
 The following checks are enabled by ``_LIBCPP_DEBUG``:
 
+  * Many algorithms, such as ``binary_search``, ``merge``, ``next_permutation``, and ``sort``,
+    wrap the user-provided comparator to assert that `!comp(y, x)` whenever
+    `comp(x, y)`. This can cause the user-provided comparator to be evaluated
+    up to twice as many times as it would be without ``_LIBCPP_DEBUG``, and
+    causes the library to violate some of the Standard's complexity clauses.
+
   * FIXME: Update this list
 
 Iterator Debugging Checks


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101677.343163.patch
Type: text/x-patch
Size: 1567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210505/115d48d6/attachment.bin>


More information about the libcxx-commits mailing list