From 80702b5d1ad84dd21cfa7c023810ec2c36991307 Mon Sep 17 00:00:00 2001 From: Kyle Dent Date: Wed, 28 Jan 2015 11:33:49 -0800 Subject: [PATCH] Fixing a -Wshorten-64-32 issues in folly for liger. Summary: Normally I would use the folly::to<> function, but it would cause a circular dependency, so I just added a static cast Test Plan: Ran on iOS and ran the folly tests Reviewed By: seanc@fb.com Subscribers: lucian, mpawlowski, marcelo, tudorb, aalexandre, seanc, folly-diffs@ FB internal diff: D1806632 Signature: t1:1806632:1422416646:b8104f18f90eb7457f2f358428f2bd800f8f1db5 --- folly/Range.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/folly/Range.h b/folly/Range.h index f22d30e9..2ce83f8d 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -389,7 +389,13 @@ public: const size_type osize = o.size(); const size_type msize = std::min(tsize, osize); int r = traits_type::compare(data(), o.data(), msize); - if (r == 0) r = tsize - osize; + if (r == 0 && tsize != osize) { + // We check the signed bit of the subtraction and bit shift it + // to produce either 0 or 2. The subtraction yields the + // comparison values of either -1 or 1. + r = (static_cast( + (osize - tsize) >> (CHAR_BIT * sizeof(size_t) - 1)) << 1) - 1; + } return r; } -- 2.34.1