From 0f66190aefa0c53648d549738a2bb312a309c2d9 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 12 Apr 2018 23:56:07 +0000 Subject: [PATCH] [libcxx] [test] Avoid MSVC truncation warnings. MSVC emits "warning C4244: 'initializing': conversion from 'int' to 'short', possible loss of data" when it sees pair constructed from (whatever, 4), because int is being truncated to short within pair's constructor. (The compiler doesn't take into account the fact that 4 is a literal at the callsite; it generates this warning when the constructor is instantiated, because it might be called with a runtime-valued int that would actually truncate.) Instead of static_cast, we can simply change short to int in these tests, without affecting the pair operations that they're trying to test: move assignment, convert copy construction, and convert move construction. Fixes D45016. llvm-svn: 329973 --- .../utility/pairs/pairs.pair/assign_rv_pair.pass.cpp | 2 +- .../utility/pairs/pairs.pair/const_pair_U_V.pass.cpp | 4 ++-- .../utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp index 38089200e4da..f02e24b24140 100644 --- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp @@ -49,7 +49,7 @@ int CountAssign::moved = 0; int main() { { - typedef std::pair, short> P; + typedef std::pair, int> P; P p1(std::unique_ptr(new int(3)), 4); P p2; p2 = std::move(p1); diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp index 715b65537761..d2cb6b10984e 100644 --- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp @@ -57,7 +57,7 @@ struct ImplicitT { int main() { { - typedef std::pair P1; + typedef std::pair P1; typedef std::pair P2; const P1 p1(3, 4); const P2 p2 = p1; @@ -154,7 +154,7 @@ int main() } #if TEST_STD_VER > 11 { - typedef std::pair P1; + typedef std::pair P1; typedef std::pair P2; constexpr P1 p1(3, 4); constexpr P2 p2 = p1; diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp index f5d3bb621deb..7e40bed21820 100644 --- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp @@ -67,7 +67,7 @@ struct ImplicitT { int main() { { - typedef std::pair, short> P1; + typedef std::pair, int> P1; typedef std::pair, long> P2; P1 p1(std::unique_ptr(), 4); P2 p2 = std::move(p1);