From 71800b5b3ca4706995b1e7eff39c2bfcb09a0fb7 Mon Sep 17 00:00:00 2001 From: Jan Bouwer Date: Tue, 14 Nov 2023 10:39:10 +1100 Subject: [PATCH] Fix overflow warning in `print_helper.hpp`. #398 - (Implicitly) printing a big enough type results in: "warning: overflow in expression; result is 2147483347 with type 'int' [-Winteger-overflow]". - Fixed by promoting the calculation to 'std::streamsize'. --- include/boost/test/tools/detail/print_helper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/test/tools/detail/print_helper.hpp b/include/boost/test/tools/detail/print_helper.hpp index dafa2bd48b..8c805907ab 100644 --- a/include/boost/test/tools/detail/print_helper.hpp +++ b/include/boost/test/tools/detail/print_helper.hpp @@ -97,7 +97,7 @@ struct print_log_value { std::streamsize set_precision( std::ostream& ostr, mpl::false_ ) { if( std::numeric_limits::is_specialized && std::numeric_limits::radix == 2 ) - return ostr.precision( 2 + std::numeric_limits::digits * 301/1000 ); + return ostr.precision( 2 + std::streamsize(std::numeric_limits::digits) * 301/1000 ); else if ( std::numeric_limits::is_specialized && std::numeric_limits::radix == 10 ) { #ifdef BOOST_NO_CXX11_NUMERIC_LIMITS // (was BOOST_NO_NUMERIC_LIMITS_LOWEST but now deprecated).