This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Avoid applying unary minus to unsigned integers.
ClosedPublic

Authored by STL_MSFT on Jun 29 2016, 4:20 PM.

Details

Summary

Avoid applying unary minus to unsigned integers.

This is confusing because first you have to remember what unsigned negation does, then you have to worry about the usual arithmetic conversions during the comparison. It's simpler to express the most negative values as "blah - 1" expressions, and then the only UAC involved is widening int to long long and that's easy.

Fixes MSVC warning/error C4146 "unary minus operator applied to unsigned type, result still unsigned".

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 62302.Jun 29 2016, 4:20 PM
STL_MSFT retitled this revision from to [libcxx] [test] Avoid applying unary minus to unsigned integers..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF accepted this revision.Jun 29 2016, 9:27 PM
EricWF edited edge metadata.
This revision is now accepted and ready to land.Jun 29 2016, 9:27 PM
EricWF closed this revision.Jun 29 2016, 9:29 PM

r274203.