This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] NFC: suppress warning on systems where sizeof(int) == sizeof(long)
AbandonedPublic

Authored by bcraig on Jan 22 2016, 12:09 PM.

Details

Reviewers
mclow.lists
Summary

The old code produced a couple of these warnings...

src/string.cpp:95:11: warning: comparison of constant -2147483648 with expression of type 'long' (range [-2147483648, 2147483647]) is always false [-Wtautological-constant-out-of-range-compare]
  if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
      ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
src/string.cpp:95:11: note: place two sets of parentheses around the constant to silence this warning
  if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)

This patch follows the advice of the note, as the comparison is reasonable on many 64-bit systems.

Diff Detail

Event Timeline

bcraig updated this revision to Diff 45722.Jan 22 2016, 12:09 PM
bcraig retitled this revision from to [libcxx] NFC: suppress warning on systems where sizeof(int) == sizeof(long).
bcraig updated this object.
bcraig added a reviewer: mclow.lists.
bcraig updated this object.
bcraig updated this object.
bcraig added a subscriber: cfe-commits.
EricWF added a subscriber: EricWF.Jan 22 2016, 7:05 PM

How are you getting this warning? I can't generate it with Clang 3.8 on 64bit linux with -m32. In that configuration int and long have the same size.

bcraig abandoned this revision.Jan 25 2016, 6:11 AM

Looks like I found an out-of-tree warning in our compiler. Sorry about the noise. Abandoning.