Page MenuHomePhabricator

NFC: Fix -Wsign-compare warnings on 32-bit builds
ClosedPublic

Authored by hubert.reinterpretcast on Oct 16 2020, 8:29 PM.

Details

Summary

Comparing 32-bit ptrdiff_t against 32-bit unsigned results in -Wsign-compare warnings for both GCC and Clang.

The warning for the cases in question appear to identify an issue where the ptrdiff_t value would be mutated via conversion to an unsigned type.

The warning is resolved by using the usual arithmetic conversions to safely preserve the value of the unsigned operand while trying to convert to a signed type. Host platforms where unsigned has the same width as unsigned long long will need to make a different change, but using an explicit cast has disadvantages that can be avoided for now.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 16 2020, 8:29 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
hubert.reinterpretcast requested review of this revision.Oct 16 2020, 8:29 PM
This revision is now accepted and ready to land.Oct 20 2020, 7:22 AM
This revision was landed with ongoing or failed builds.Oct 20 2020, 5:52 PM
This revision was automatically updated to reflect the committed changes.