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>


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>
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D33708: [t... Billy Robert O'Neal III via Phabricator via cfe-commits

Reply via email to