[libcxx-commits] [libcxx] 6d8abe4 - [libcxx] [test] Add casts to avoid signed/unsigned mismatch warnings on MSVC++

Billy Robert O'Neal III via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 14 01:11:20 PST 2020


Author: Billy Robert O'Neal III
Date: 2020-01-14T01:11:10-08:00
New Revision: 6d8abe424a77f736fbed114eeac574b9bfe6b0c1

URL: https://github.com/llvm/llvm-project/commit/6d8abe424a77f736fbed114eeac574b9bfe6b0c1
DIFF: https://github.com/llvm/llvm-project/commit/6d8abe424a77f736fbed114eeac574b9bfe6b0c1.diff

LOG: [libcxx] [test] Add casts to avoid signed/unsigned mismatch warnings on MSVC++

A bug was filed that these warnings should not be emitted as DevCom-883961. ( https://developercommunity.visualstudio.com/content/problem/883961/c4389-signedunsigned-mismatch-should-not-be-emitte.html )

Added: 
    

Modified: 
    libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
    libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
    libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
index 8dedddb4c20b..37d5759f833c 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
@@ -26,7 +26,7 @@ TEST_CONSTEXPR bool test_constexpr() {
 
     auto it = std::remove_copy(std::begin(ia), std::end(ia), std::begin(ib), 5);
 
-    return std::distance(std::begin(ib), it) == (std::size(ia) - 2)   // we removed two elements
+    return std::distance(std::begin(ib), it) == static_cast<int>(std::size(ia) - 2)   // we removed two elements
         && std::none_of(std::begin(ib), it, [](int a) {return a == 5;})
         && std::all_of (it, std::end(ib),   [](int a) {return a == 0;})
            ;

diff  --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
index 7d10c6bd759a..01b382ba004d 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
@@ -30,7 +30,7 @@ TEST_CONSTEXPR bool test_constexpr() {
 
     auto it = std::remove_copy_if(std::begin(ia), std::end(ia), std::begin(ib), equalToTwo);
 
-    return std::distance(std::begin(ib), it) == (std::size(ia) - 1)   // we removed one element
+    return std::distance(std::begin(ib), it) == static_cast<int>(std::size(ia) - 1)   // we removed one element
         && std::none_of(std::begin(ib), it, equalToTwo)
         && std::all_of (it, std::end(ib), [](int a) {return a == 0;})
            ;

diff  --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
index 6967c446b75d..be3e6afd0472 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
@@ -25,7 +25,7 @@ TEST_CONSTEXPR bool test_constexpr() {
 
     auto it = std::reverse_copy(std::begin(ia), std::end(ia), std::begin(ib));
 
-    return std::distance(std::begin(ib), it) == std::size(ia)
+    return std::distance(std::begin(ib), it) == static_cast<int>(std::size(ia))
         && std::equal   (std::begin(ia), std::end(ia), std::rbegin(ib))
            ;
     }


        


More information about the libcxx-commits mailing list