Commit 67a4edad authored by Jim Meyering's avatar Jim Meyering Committed by Viswanath Sivakumar

folly/small_vector.h: avoid -Wsign-compare error

Summary:
* folly/small_vector.h (moveToUninitialized): Do not mix
signed and unsigned for-loop index/limit.  Instead, eliminate
the intermediate "count" altogether and iterate as long as
"first" is not equal to "last". Otherwise, gcc-4.9 fails with e.g.,
folly/small_vector.h:115:18: 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: soren@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1767844

Tasks: 5941250

Signature: t1:1767844:1420601608:987fd7f7d44197ed9919910c9b559b37fbe421b6
parent b6c430e1
......@@ -109,10 +109,9 @@ namespace detail {
!FOLLY_IS_TRIVIALLY_COPYABLE(T)
>::type
moveToUninitialized(T* first, T* last, T* out) {
auto const count = last - first;
std::size_t idx = 0;
try {
for (; idx < count; ++first, ++idx) {
for (; first != last; ++first, ++idx) {
new (&out[idx]) T(std::move(*first));
}
} catch (...) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment