diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index e0fc90b..d6db024 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -85,6 +85,22 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c ++test_errors(); } +// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers. +// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid +// the dependency we just disable the warnings. +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4389) +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wsign-compare") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-compare" +# endif +#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + template inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { @@ -119,6 +135,16 @@ template inline void test_ne_impl( char const * expr1, char co } } +#if defined(_MSC_VER) +# pragma warning(pop) +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wsign-compare") +# pragma clang diagnostic pop +# endif +#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 +# pragma GCC diagnostic pop +#endif + } // namespace detail inline int report_errors()