[libcxx] r288747 - [libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.
Stephan T. Lavavej via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 5 17:13:29 PST 2016
Author: stl_msft
Date: Mon Dec 5 19:13:29 2016
New Revision: 288747
URL: http://llvm.org/viewvc/llvm-project?rev=288747&view=rev
Log:
[libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.
Add static_cast<int>. In these cases, the values are guaranteed to be small-ish,
and they're being compared to int elements.
test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
Use int instead of unsigned to iterate from 0 to 10.
Modified:
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp Mon Dec 5 19:13:29 2016
@@ -53,7 +53,7 @@ test1()
OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
assert(base(r) == ib+N);
for (unsigned i = 0; i < N; ++i)
- assert(*ib[i] == i);
+ assert(*ib[i] == static_cast<int>(i));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp Mon Dec 5 19:13:29 2016
@@ -53,7 +53,7 @@ test1()
OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
assert(base(r) == ib);
for (unsigned i = 0; i < N; ++i)
- assert(*ib[i] == i);
+ assert(*ib[i] == static_cast<int>(i));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp Mon Dec 5 19:13:29 2016
@@ -35,5 +35,5 @@ int main()
for_each_test(0));
assert(f.count == s);
for (unsigned i = 0; i < s; ++i)
- assert(ia[i] == i+1);
+ assert(ia[i] == static_cast<int>(i+1));
}
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp Mon Dec 5 19:13:29 2016
@@ -40,7 +40,7 @@ test()
InIter2(ib), InIter2(ib+N), OutIter(ic));
assert(base(r) == ic+2*N);
assert(ic[0] == 0);
- assert(ic[2*N-1] == 2*N-1);
+ assert(ic[2*N-1] == static_cast<int>(2*N-1));
assert(std::is_sorted(ic, ic+2*N));
delete [] ic;
delete [] ib;
@@ -62,7 +62,7 @@ test()
InIter2(ib), InIter2(ib+N), OutIter(ic));
assert(base(r) == ic+2*N);
assert(ic[0] == 0);
- assert(ic[2*N-1] == 2*N-1);
+ assert(ic[2*N-1] == static_cast<int>(2*N-1));
assert(std::is_sorted(ic, ic+2*N));
delete [] ic;
delete [] ib;
Modified: libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp Mon Dec 5 19:13:29 2016
@@ -46,7 +46,7 @@ test()
OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
assert(base(r) == ic+2*N);
- assert(ic[0] == 2*N-1);
+ assert(ic[0] == static_cast<int>(2*N-1));
assert(ic[2*N-1] == 0);
assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
assert(pred.count() <= (N + N - 1));
@@ -70,7 +70,7 @@ test()
OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
assert(base(r) == ic+2*N);
- assert(ic[0] == 2*N-1);
+ assert(ic[0] == static_cast<int>(2*N-1));
assert(ic[2*N-1] == 0);
assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
assert(pred.count() <= (N + N - 1));
Modified: libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp?rev=288747&r1=288746&r2=288747&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp Mon Dec 5 19:13:29 2016
@@ -52,18 +52,18 @@ int main()
{
{
std::deque<int> c = make<std::deque<int> >(10);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c[i] == i);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
{
const std::deque<int> c = make<std::deque<int> >(10);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c[i] == i);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
@@ -71,18 +71,18 @@ int main()
#if TEST_STD_VER >= 11
{
std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c[i] == i);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
{
const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c[i] == i);
- for (unsigned i = 0; i < 10; ++i)
+ for (int i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
More information about the cfe-commits
mailing list