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

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 22 16:50:50 PST 2016


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>();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27020.78989.patch
Type: text/x-patch
Size: 2021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161123/6f72ffe7/attachment-0001.bin>


More information about the cfe-commits mailing list