This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.
ClosedPublic

Authored by STL_MSFT on Nov 22 2016, 4:55 PM.

Details

Summary

[libcxx] [test] Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.

Various changes:

test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int).
static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small).

test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
This is comparing an int remote-element to size_t. The values in question are small and non-negative,
so either type is fine. I think that converting int to size_t is marginally better here than the reverse.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>.

test/std/strings/basic.string/string.access/index.pass.cpp
We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t).

"v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 78995.Nov 22 2016, 4:55 PM
STL_MSFT retitled this revision from to [libcxx] [test] Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF accepted this revision.Dec 2 2016, 11:40 PM
EricWF edited edge metadata.
This revision is now accepted and ready to land.Dec 2 2016, 11:40 PM
STL_MSFT closed this revision.Dec 5 2016, 5:28 PM

Thanks, r288749.