[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

Billy Robert O'Neal III via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 17:19:21 PDT 2017


BillyONeal created this revision.

In T_size_size.pass, there is an explicit template argument to std::min to ask
for unsigned, to avoid type deduction errors. However, C1XX' warnings still
hate this use, because a 64 bit value (a size_t) is being passed to a function
accepting an unsigned (a 32 bit value).

Instead of supplying explicit template arguments, make all the things involved
be unsigned, so there are no type mismatches (and thus, no warning).


https://reviews.llvm.org/D32574

Files:
  test/std/strings/basic.string/string.cons/T_size_size.pass.cpp


Index: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -36,7 +36,7 @@
         S s2(sv, pos, n);
         LIBCPP_ASSERT(s2.__invariants());
         assert(pos <= sv.size());
-        unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+        unsigned rlen = std::min(static_cast<unsigned>(sv.size()) - pos, n);
         assert(s2.size() == rlen);
         assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
         assert(s2.get_allocator() == A());
@@ -68,7 +68,7 @@
         S s2(sv, pos, n, a);
         LIBCPP_ASSERT(s2.__invariants());
         assert(pos <= sv.size());
-        unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+        unsigned rlen = std::min(static_cast<unsigned>(sv.size()) - pos, n);
         assert(s2.size() == rlen);
         assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
         assert(s2.get_allocator() == a);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32574.96853.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170427/e41ef72e/attachment.bin>


More information about the cfe-commits mailing list