[libcxx-commits] [libcxx] 5dfbcc5 - [libc++] [test] Fix nodiscard_extensions.pass.cpp in _LIBCPP_DEBUG mode.

Arthur O'Dwyer via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 22 09:17:54 PDT 2021


Author: Arthur O'Dwyer
Date: 2021-04-22T12:17:32-04:00
New Revision: 5dfbcc5ae953b786f493ce5e9d78a4b5c5e55229

URL: https://github.com/llvm/llvm-project/commit/5dfbcc5ae953b786f493ce5e9d78a4b5c5e55229
DIFF: https://github.com/llvm/llvm-project/commit/5dfbcc5ae953b786f493ce5e9d78a4b5c5e55229.diff

LOG: [libc++] [test] Fix nodiscard_extensions.pass.cpp in _LIBCPP_DEBUG mode.

`std::clamp(2, 1, 3, std::greater<int>())` has UB because (1 > 3) is false.
Swap the operands to fix the _LIBCPP_ASSERT failure in this test.

Added: 
    

Modified: 
    libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
index 1b34e37092e88..74f2f239bf3e7 100644
--- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
+++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
@@ -46,7 +46,7 @@ void test_algorithms() {
   std::binary_search(std::begin(arr), std::end(arr), 1, std::greater<int>());
 #if TEST_STD_VER >= 17
   std::clamp(2, 1, 3);
-  std::clamp(2, 1, 3, std::greater<int>());
+  std::clamp(2, 3, 1, std::greater<int>());
 #endif
   std::count_if(std::begin(arr), std::end(arr), P());
   std::count(std::begin(arr), std::end(arr), 1);


        


More information about the libcxx-commits mailing list