From a20f8f22e61cf245643406b1468a7c7947d56576 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sat, 19 Oct 2024 15:48:08 +0300 Subject: [PATCH] Work around MSVC warnings in test code. --- test/api_test_helpers.hpp | 20 +++++++++++++++++++- test/lockfree.cpp | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/test/api_test_helpers.hpp b/test/api_test_helpers.hpp index b3da35e5..d9c272be 100644 --- a/test/api_test_helpers.hpp +++ b/test/api_test_helpers.hpp @@ -441,6 +441,12 @@ void test_additive_operators_with_type_and_test() #pragma warning(pop) #endif +#if defined(BOOST_MSVC) +#pragma warning(push) +// cast truncates constant value +#pragma warning(disable: 4310) +#endif + template< template< typename > class Wrapper, typename T, typename D, typename AddType > void test_additive_operators_with_type(T value, D delta) { @@ -698,6 +704,10 @@ void test_additive_operators_with_type(T value, D delta) test_additive_operators_with_type_and_test< Wrapper, T, D, AddType >(); } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + template< template< typename > class Wrapper, typename T, typename D > void test_additive_operators(T value, D delta) { @@ -1169,7 +1179,15 @@ void do_test_integral_api(boost::false_type) { test_base_operators< Wrapper, T >(42, 43, 44); test_additive_operators< Wrapper, T, T >(42, 17); +#if defined(BOOST_MSVC) +#pragma warning(push) +// cast truncates constant value +#pragma warning(disable: 4310) +#endif test_bit_operators< Wrapper, T >((T)0x5f5f5f5f5f5f5f5fULL, (T)0xf5f5f5f5f5f5f5f5ULL); +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif /* test for unsigned overflow/underflow */ test_additive_operators< Wrapper, T, T >((T)-1, 1); @@ -1185,7 +1203,7 @@ void do_test_integral_api(boost::true_type) do_test_integral_api< Wrapper, T >(boost::false_type()); test_additive_wrap< Wrapper, T >(0u); - BOOST_CONSTEXPR_OR_CONST T all_ones = ~(T)0u; + BOOST_CONSTEXPR_OR_CONST T all_ones = (T)-1; test_additive_wrap< Wrapper, T >(all_ones); BOOST_CONSTEXPR_OR_CONST T max_signed_twos_compl = all_ones >> 1; test_additive_wrap< Wrapper, T >(all_ones ^ max_signed_twos_compl); diff --git a/test/lockfree.cpp b/test/lockfree.cpp index 297d7134..0ac16435 100644 --- a/test/lockfree.cpp +++ b/test/lockfree.cpp @@ -17,6 +17,11 @@ #include #include "aligned_object.hpp" +#if defined(BOOST_MSVC) +// conditional expression is constant +#pragma warning(disable: 4127) +#endif + static const char* const lock_free_level[] = { "never",