diff options
| author | Stephan T. Lavavej <stl@exchange.microsoft.com> | 2016-12-08 21:38:44 +0000 |
|---|---|---|
| committer | Stephan T. Lavavej <stl@exchange.microsoft.com> | 2016-12-08 21:38:44 +0000 |
| commit | 4e19c47556b227b5f83b7882effa364c181028d5 (patch) | |
| tree | ac033e076d92f507e9dad964f142580403d65f89 /libcxx/test/std/algorithms/alg.sorting | |
| parent | a0d87857e0285c96f59823cdf0f3c3798044bf3e (diff) | |
| download | bcm5719-llvm-4e19c47556b227b5f83b7882effa364c181028d5.tar.gz bcm5719-llvm-4e19c47556b227b5f83b7882effa364c181028d5.zip | |
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 6/7.
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t
(instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that
difference_type is used, and we're shuffling a plain array.)
test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
(Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits.
Then, store the result of subtracting two RanIts as difference_type instead of long
(which truncates on LLP64 architectures like MSVC x64).
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can store the result of
subtracting two pointers as std::ptrdiff_t (instead of int).
test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
(Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here,
where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can
have 64-bit pos_type (to handle large files) even when they have 32-bit size_t.
Fixes D27543.
llvm-svn: 289110
Diffstat (limited to 'libcxx/test/std/algorithms/alg.sorting')
| -rw-r--r-- | libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp | 5 | ||||
| -rw-r--r-- | libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp index ebb876709b5..ea1e7dfe9fa 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp @@ -16,6 +16,7 @@ // sort(Iter first, Iter last); #include <algorithm> +#include <iterator> #include <cassert> template <class RI> @@ -23,9 +24,11 @@ void test_sort_helper(RI f, RI l) { typedef typename std::iterator_traits<RI>::value_type value_type; + typedef typename std::iterator_traits<RI>::difference_type difference_type; + if (f != l) { - long len = l - f; + difference_type len = l - f; value_type* save(new value_type[len]); do { diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp index 2721c9c01ec..74a876cee19 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp @@ -16,6 +16,7 @@ // stable_sort(Iter first, Iter last); #include <algorithm> +#include <iterator> #include <cassert> template <class RI> @@ -23,9 +24,11 @@ void test_sort_helper(RI f, RI l) { typedef typename std::iterator_traits<RI>::value_type value_type; + typedef typename std::iterator_traits<RI>::difference_type difference_type; + if (f != l) { - long len = l - f; + difference_type len = l - f; value_type* save(new value_type[len]); do { |

