[libcxx] r288748 - [libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 17:13:40 PST 2016


Author: stl_msft
Date: Mon Dec  5 19:13:40 2016
New Revision: 288748

URL: http://llvm.org/viewvc/llvm-project?rev=288748&view=rev
Log:
[libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.

Change "unsigned n = 0;" to "int n = 0;". It's being compared to int elements and ptrdiff_t distances.

test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
This one's a little special, but not really. "*i == n" is comparing MoveOnly to n.
MoveOnly is implicitly constructible from int, so int is the correct type to use here.

Modified:
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp Mon Dec  5 19:13:40 2016
@@ -28,7 +28,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A(10));
         C c = c0;
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -43,7 +43,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A(10));
         C c = c0;
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -57,7 +57,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A());
         C c = c0;
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp Mon Dec  5 19:13:40 2016
@@ -27,7 +27,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A(10));
         C c(c0, A(9));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -41,7 +41,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A(10));
         C c(c0, A(9));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -56,7 +56,7 @@ int main()
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c0(std::begin(t), std::end(t), A());
         C c(c0, A());
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp Mon Dec  5 19:13:40 2016
@@ -23,7 +23,7 @@ int main()
         typedef int T;
         typedef std::forward_list<T> C;
         C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == 10);
@@ -33,7 +33,7 @@ int main()
         typedef int T;
         typedef std::forward_list<T, min_allocator<T>> C;
         C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == 10);

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp Mon Dec  5 19:13:40 2016
@@ -25,7 +25,7 @@ int main()
         typedef test_allocator<T> A;
         typedef std::forward_list<T, A> C;
         C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == 10);
@@ -37,7 +37,7 @@ int main()
         typedef min_allocator<T> A;
         typedef std::forward_list<T, A> C;
         C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A());
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == 10);

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp Mon Dec  5 19:13:40 2016
@@ -30,7 +30,7 @@ int main()
         typedef std::move_iterator<T*> I;
         C c0(I(std::begin(t)), I(std::end(t)), A(10));
         C c = std::move(c0);
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -45,7 +45,7 @@ int main()
         typedef std::move_iterator<T*> I;
         C c0(I(std::begin(t)), I(std::end(t)), A(10));
         C c = std::move(c0);
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -61,7 +61,7 @@ int main()
         typedef std::move_iterator<T*> I;
         C c0(I(std::begin(t)), I(std::end(t)), A());
         C c = std::move(c0);
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp Mon Dec  5 19:13:40 2016
@@ -27,7 +27,7 @@ int main()
         typedef input_iterator<const T*> I;
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c(I(std::begin(t)), I(std::end(t)));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -39,7 +39,7 @@ int main()
         typedef input_iterator<const T*> I;
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c(I(std::begin(t)), I(std::end(t)));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp?rev=288748&r1=288747&r2=288748&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp Mon Dec  5 19:13:40 2016
@@ -30,7 +30,7 @@ int main()
         typedef input_iterator<const T*> I;
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c(I(std::begin(t)), I(std::end(t)), A(13));
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));
@@ -44,7 +44,7 @@ int main()
         typedef input_iterator<const T*> I;
         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
         C c(I(std::begin(t)), I(std::end(t)), A());
-        unsigned n = 0;
+        int n = 0;
         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
             assert(*i == n);
         assert(n == std::end(t) - std::begin(t));




More information about the cfe-commits mailing list