diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 614654a3..37de4346 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1367,6 +1367,24 @@ private: #endif } +/* GCC and clang (including clang-win toolsets) will generate warnings when the + * KeyEqual predicate returns an integral type such as std::size_t because the + * implementation of __builtin_expect() accepts long as its argument types. + * + * Because we can't control this, it's easiest to simply silence the warning + * instead of introducing any potential performance pitfalls. + */ +#if defined(BOOST_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +#if defined(BOOST_CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#pragma clang diagnostic ignored "-Wsign-conversion" +#endif + template BOOST_FORCEINLINE iterator find_impl( const Key& x,std::size_t pos0,std::size_t hash)const @@ -1381,7 +1399,7 @@ private: prefetch_elements(p); do{ auto n=unchecked_countr_zero(mask); - if(BOOST_LIKELY(static_cast(pred()(x,key_from(p[n]))))){ + if(BOOST_LIKELY(pred()(x,key_from(p[n])))){ return {pg,n,p+n}; } mask&=mask-1; @@ -1394,6 +1412,13 @@ private: while(BOOST_LIKELY(pb.next(arrays.groups_size_mask))); return {}; // TODO end() does not work (returns const_iterator) } +#if defined(BOOST_CLANG) +#pragma clang diagnostic pop /* ignored "-Wshorten-64-to-32", "-Wsign-conversion" */ +#endif + +#if defined(BOOST_GCC) +#pragma GCC diagnostic pop /* ignored "-Wsign-conversion" */ +#endif template BOOST_FORCEINLINE std::pair emplace_impl(Args&&... args)