[libcxx-commits] [PATCH] D96074: [test] std::nth_element regression

Jordan Rupprecht via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 4 13:02:55 PST 2021


rupprecht created this revision.
rupprecht requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This shows a test case that should pass, but fails, due to a regression in std::nth_element after D93557 <https://reviews.llvm.org/D93557>. The last two elements should be 6 and 7, but they are 7 and 6.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96074

Files:
  libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp


Index: libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
+++ libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
@@ -47,6 +47,13 @@
         assert(input[4] == 4);
         assert(input[5] + input[6] == 5 + 9);
     }
+
+    {
+      T input[] = {0, 1, 2, 3, 4, 5, 7, 6};
+      std::nth_element(Iter(input), Iter(input + 6), Iter(input + 8));
+      assert(input[6] == 6);
+      assert(input[7] == 7);
+    }
     return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96074.321551.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210204/1f850095/attachment.bin>


More information about the libcxx-commits mailing list