STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix MSVC warning C4245 "conversion from 'X' to 'Y', 
signed/unsigned mismatch", part 7/12.

When initializing unsigned integers to their maximum values, change "const T 
M(~0);" to "const T M(static_cast<T>(-1));".

~0 and -1 are equivalent, but I consider the -1 form to be significantly 
clearer (and more consistent with other tests).


https://reviews.llvm.org/D27020

Files:
  test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
  test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
  test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
  test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp


Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
@@ -72,7 +72,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
@@ -36,7 +36,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
@@ -37,7 +37,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
@@ -37,7 +37,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();


Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
@@ -72,7 +72,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
@@ -36,7 +36,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
@@ -37,7 +37,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
Index: test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
===================================================================
--- test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
+++ test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
@@ -37,7 +37,7 @@
     test1<T, 0, 0, 0>();
     test1<T, 0, 1, 2>();
     test1<T, 1, 1, 2>();
-    const T M(~0);
+    const T M(static_cast<T>(-1));
     test1<T, 0, 0, M>();
     test1<T, 0, M-2, M>();
     test1<T, 0, M-1, M>();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to