[PATCH] D33708: [test] [libcxx] Disable MSVC++'s compare(a, b) implies !compare(b, a) assertion in predicate application count tests

Billy Robert O'Neal III via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 19:54:15 PDT 2017


BillyONeal created this revision.

Turn off MSVC++'s comp(a, b) implies !comp(b, a) assertion in tests that are checking for predicate counts.

There should be no functionality change for libcxx as it does not look for the _ITERATOR_DEBUG_LEVEL macro.

While this assert is technically out of contract because the standard specifies exact operation counts for these algorithms, in practice users using !less t
o implement greater is a fairly common mistake, and this assert turns out to be highly compatible. Note also that in the inplace_merge case, users can't even rely on exact application counts here, so the complexity bound is probably overspecified in the standard.


https://reviews.llvm.org/D33708

Files:
  test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
  test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
  test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp


Index: test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
===================================================================
--- test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
+++ test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
@@ -17,6 +17,10 @@
 //
 //  Complexity: At most (3/2) * t.size() applications of the corresponding predicate.
 
+// Disable MSVC++'s "comp(a, b) implies !comp(b, a)" assertion:
+#undef _ITERATOR_DEBUG_LEVEL
+#define _ITERATOR_DEBUG_LEVEL 0
+
 #include <algorithm>
 #include <functional>
 #include <cassert>
Index: test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
===================================================================
--- test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
+++ test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -15,6 +15,10 @@
 //   void
 //   inplace_merge(Iter first, Iter middle, Iter last, Compare comp);
 
+// Disable MSVC++'s "comp(a, b) implies !comp(b, a)" assertion:
+#undef _ITERATOR_DEBUG_LEVEL
+#define _ITERATOR_DEBUG_LEVEL 0
+
 #include <algorithm>
 #include <functional>
 #include <random>
Index: test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
===================================================================
--- test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
+++ test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -14,6 +14,10 @@
 //   void
 //   make_heap(Iter first, Iter last, Compare comp);
 
+// Disable MSVC++'s "comp(a, b) implies !comp(b, a)" assertion:
+#undef _ITERATOR_DEBUG_LEVEL
+#define _ITERATOR_DEBUG_LEVEL 0
+
 #include <algorithm>
 #include <functional>
 #include <memory>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33708.100817.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170531/d0a6e89f/attachment.bin>


More information about the cfe-commits mailing list