From: Jim Meyering Date: Wed, 7 Jan 2015 16:13:57 +0000 (-0800) Subject: folly/Format-inl.h: avoid -Wsign-compare error X-Git-Tag: v0.22.0~30 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=453a7e48b8e998183f36048cbf11c2ec6daf33b5;p=folly.git folly/Format-inl.h: avoid -Wsign-compare error Summary: * folly/Format-inl.h (IndexableTraitsSeq::at): Add an explicit int-to-size_t cast (ok here, since we've just confirmed that the value is not negative) to avoid this error from gcc-4.9: folly/Format-inl.h:947:29: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] Test Plan: Run this and note there are fewer errors than before: fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo Reviewed By: tjackson@fb.com Subscribers: trunkagent, net-systems@, folly-diffs@ FB internal diff: D1770193 Tasks: 5941250 Signature: t1:1770193:1420670569:83ac19c2ca8cd408d7c86d7dce49e2d4b418941a --- diff --git a/folly/Format-inl.h b/folly/Format-inl.h index fb756197..b72ec861 100644 --- a/folly/Format-inl.h +++ b/folly/Format-inl.h @@ -944,7 +944,7 @@ struct IndexableTraitsSeq : public FormatTraitsBase { static const value_type& at(const C& c, int idx, const value_type& dflt) { - return (idx >= 0 && idx < c.size()) ? c.at(idx) : dflt; + return (idx >= 0 && size_t(idx) < c.size()) ? c.at(idx) : dflt; } };