From 4b1caad727677cd0d50ffdb180289ba7000d6165 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 19 Jan 2022 17:30:56 +0200 Subject: [PATCH] Avoid sign conversion warnings in error_code::value --- include/boost/system/detail/error_code.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index eaf4324..910a9af 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -188,7 +188,11 @@ public: #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) std::error_code const& ec = *reinterpret_cast( d2_ ); - return ec.value() + 1000 * static_cast( reinterpret_cast( &ec.category() ) % 2097143 ); // 2^21-9, prime + + unsigned cv = static_cast( ec.value() ); + unsigned ch = static_cast( reinterpret_cast( &ec.category() ) % 2097143 ); // 2^21-9, prime + + return static_cast( cv + 1000 * ch ); #else return -1;