Commit db376afe authored by Sean Cannella's avatar Sean Cannella Committed by Dave Watson

Support -Wsign-compare compilation

Summary:
Due to how Conv.h uses the less_than template inside
not-actually-static static ifs clang still ends up validating generated
code inside a FOLLY_RANGE_CHECK which is never executed due to the
templated types. This code however still generates -Wsign-compare issues
so suppress that in order to allow includers to use this flag.

A simple example will illustrate this:

uint64_t foo = 1;
int bar = folly::to<int>(foo);

Test Plan: fbmake runtests

Reviewed By: meyering@fb.com, njormrod@fb.com

Subscribers: trunkagent, folly-diffs@, bmatheny, ranjeeth, subodh, kmdent, fma, shikong, pgriess, jdelong

FB internal diff: D1731411

Signature: t1:1731411:1418243200:ed1f34a1485669c9cb18f9f6029aca70e498953c
parent 25e200e2
......@@ -340,6 +340,13 @@ struct is_negative_impl<T, false> {
constexpr static bool check(T x) { return false; }
};
// folly::to integral specializations can end up generating code
// inside what are really static ifs (not executed because of the templated
// types) that violate -Wsign-compare so suppress them in order to not prevent
// all calling code from using it.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
template <typename RHS, RHS rhs, typename LHS>
bool less_than_impl(
typename std::enable_if<
......@@ -371,6 +378,8 @@ bool less_than_impl(
return false;
}
#pragma GCC diagnostic pop
template <typename RHS, RHS rhs, typename LHS>
bool greater_than_impl(
typename std::enable_if<
......
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