[PATCH] D27542: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.

Stephan T. Lavavej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 14:04:23 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 C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.

Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.


https://reviews.llvm.org/D27542

Files:
  test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27542.80656.patch
Type: text/x-patch
Size: 14267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161207/e88076d4/attachment-0001.bin>


More information about the cfe-commits mailing list