From b6c430e1dea510e56cc170bdcf68018c6ad083c3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 6 Jan 2015 17:21:42 -0800 Subject: [PATCH] folly/FBVector.h: avoid -Wsign-compare error (simple) Summary: * folly/FBVector.h (make_window): Declare "tail" to be explicitly of the same type as "n". Otherwise, we'd use the type of std::distance, which is unsigned, and then compare that against "n" of type "size_type", which is unsigned, and we'd get this from gcc-4.9: folly/FBVector.h:1276:14: 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: philipp@fb.com, andrei.alexandrescu@fb.com Subscribers: trunkagent, njormrod, folly-diffs@ FB internal diff: D1768346 Tasks: 5941250 Signature: t1:1768346:1420594452:654dac805bb46f7c6a38b4e4102e4004720d6835 --- folly/FBVector.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/folly/FBVector.h b/folly/FBVector.h index 6abc4529..d6cd6937 100644 --- a/folly/FBVector.h +++ b/folly/FBVector.h @@ -1271,7 +1271,8 @@ private: // we have the private section first because it defines some macros assert(size() + n <= capacity()); assert(n != 0); - auto tail = std::distance(position, impl_.e_); + // The result is guaranteed to be non-negative, so use an unsigned type: + size_type tail = std::distance(position, impl_.e_); if (tail <= n) { relocate_move(position + n, position, impl_.e_); -- 2.34.1