[libcxx-commits] [libcxx] 2f30bd1 - [libc++][NFC] Make size_t -> int conversions explicit in a few PSTL tests (#213145)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 31 05:43:37 PDT 2026


Author: Michael G. Kazakov
Date: 2026-07-31T20:43:31+08:00
New Revision: 2f30bd168ccb47a82a25faba92cae4d6d0b47f0d

URL: https://github.com/llvm/llvm-project/commit/2f30bd168ccb47a82a25faba92cae4d6d0b47f0d
DIFF: https://github.com/llvm/llvm-project/commit/2f30bd168ccb47a82a25faba92cae4d6d0b47f0d.diff

LOG: [libc++][NFC] Make size_t -> int conversions explicit in a few PSTL tests (#213145)

The implicit truncating conversions that were introduced in some PSTL
tests are causing warnings on MSVC. This PR fixes that.

See
https://github.com/llvm/llvm-project/pull/212366#discussion_r3679252259
for more details.

Added: 
    

Modified: 
    libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find.pass.cpp
    libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find_pred.pass.cpp
    libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of.pass.cpp
    libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of_pred.pass.cpp
    libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp
    libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find.pass.cpp
index db78d29da73d0..d06076fa03cf9 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find.pass.cpp
@@ -101,7 +101,7 @@ struct Test {
           return; // skip the first element to avoid out-of-bounds access
         a[i] = a[i - 1];
         assert(std::adjacent_find(policy, Iter(std::begin(a)), Iter(std::end(a))) == Iter(std::begin(a) + i - 1));
-        a[i] = i;
+        a[i] = static_cast<int>(i);
       });
     }
   }

diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find_pred.pass.cpp
index 792e4f75dc17f..718e4ebfcd08d 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/pstl.adjacent_find_pred.pass.cpp
@@ -109,7 +109,7 @@ struct Test {
         a[i] = a[i - 1] + 42;
         assert(std::adjacent_find(policy, Iter(std::begin(a)), Iter(std::end(a)), Pred{}) ==
                Iter(std::begin(a) + i - 1));
-        a[i] = i;
+        a[i] = static_cast<int>(i);
       });
     }
   }

diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of.pass.cpp
index 118b34da0cb6c..071fabf533143 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of.pass.cpp
@@ -101,7 +101,7 @@ struct Test {
         assert(std::find_first_of(
                    policy, Iter1(std::begin(a)), Iter1(std::end(a)), Iter2(std::begin(b)), Iter2(std::end(b))) ==
                Iter1(std::begin(a) + i));
-        a[i] = i;
+        a[i] = static_cast<int>(i);
       });
     }
   }

diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of_pred.pass.cpp
index 1033b52e4621f..ae5ea0c71cf83 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/pstl.find_first_of_pred.pass.cpp
@@ -122,7 +122,7 @@ struct Test {
             std::find_first_of(
                 policy, Iter1(std::begin(a)), Iter1(std::end(a)), Iter2(std::begin(b)), Iter2(std::end(b)), Pred{}) ==
             Iter1(std::begin(a) + i));
-        a[i] = i;
+        a[i] = static_cast<int>(i);
       });
     }
   }

diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp
index 83f4b0f16d6c1..892d4f426787d 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp
@@ -151,7 +151,7 @@ struct Test {
             std::mismatch(
                 policy, Iter1(std::begin(lhs)), Iter1(std::end(lhs)), Iter2(std::begin(rhs)), Iter2(std::end(rhs))) ==
             std::make_pair(Iter1(std::begin(lhs) + i), Iter2(std::begin(rhs) + i)));
-        lhs[i] = i;
+        lhs[i] = static_cast<int>(i);
       });
       assert(std::mismatch(policy, Iter1(std::begin(lhs)), Iter1(std::end(lhs)), Iter2(std::begin(rhs))) ==
              std::make_pair(Iter1(std::end(lhs)), Iter2(std::end(rhs))));

diff  --git a/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp
index 89cf899a47b4c..ed27f20cc70c6 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp
@@ -183,7 +183,7 @@ struct Test {
                              Iter2(std::begin(rhs)),
                              Iter2(std::end(rhs)),
                              Pred{}) == std::make_pair(Iter1(std::begin(lhs) + i), Iter2(std::begin(rhs) + i)));
-        lhs[i] = i;
+        lhs[i] = static_cast<int>(i);
       });
       assert(std::mismatch(policy, Iter1(std::begin(lhs)), Iter1(std::end(lhs)), Iter2(std::begin(rhs)), Pred{}) ==
              std::make_pair(Iter1(std::end(lhs)), Iter2(std::end(rhs))));


        


More information about the libcxx-commits mailing list