[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
Fri Apr 30 16:57:30 PDT 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

  `__debug_less` ends up running the comparator up-to-twice per comparison,
  because whenever `(x < y)` it goes on to verify that `!(y < x)`.
  This breaks the strict "Complexity" guarantees of algorithms like
  `inplace_merge`, which we test in the test suite. So, just skip the
  complexity assertions in debug mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101677

Files:
  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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101677.342089.patch
Type: text/x-patch
Size: 827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210430/d9c5da6c/attachment.bin>


More information about the libcxx-commits mailing list