From db376afe1c715a3aa89faebe410ba2acaae2df33 Mon Sep 17 00:00:00 2001 From: Sean Cannella Date: Wed, 10 Dec 2014 13:15:55 -0800 Subject: [PATCH] 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(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 --- folly/Traits.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/folly/Traits.h b/folly/Traits.h index 132e0f2b..14e02f5a 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -340,6 +340,13 @@ struct is_negative_impl { 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 bool less_than_impl( typename std::enable_if< @@ -371,6 +378,8 @@ bool less_than_impl( return false; } +#pragma GCC diagnostic pop + template bool greater_than_impl( typename std::enable_if< -- 2.34.1