From 32bf67f74868d073a6ff9949e8fe1d6ca7ae2fda Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Jan 2023 19:56:34 +0200 Subject: [PATCH] error_code wrapping std::error_code should never compare equal to error_code not wrapping std (because of hash_value.) Fixes #101. --- include/boost/system/detail/error_code.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index 1189fb4..2b387fb 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -403,7 +403,12 @@ public: { #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) - if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 ) + bool s1 = lhs.lc_flags_ == 1; + bool s2 = rhs.lc_flags_ == 1; + + if( s1 != s2 ) return false; + + if( s1 && s2 ) { std::error_code const& e1 = *reinterpret_cast( lhs.d2_ ); std::error_code const& e2 = *reinterpret_cast( rhs.d2_ ); @@ -421,7 +426,13 @@ public: { #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) - if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 ) + bool s1 = lhs.lc_flags_ == 1; + bool s2 = rhs.lc_flags_ == 1; + + if( s1 < s2 ) return true; + if( s2 < s1 ) return false; + + if( s1 && s2 ) { std::error_code const& e1 = *reinterpret_cast( lhs.d2_ ); std::error_code const& e2 = *reinterpret_cast( rhs.d2_ );