From ee0ca512eade3c3e1e0652dc5cbc4c728a21a551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 17 Jan 2017 23:31:03 +0100 Subject: [PATCH] Force short-circuited evaluation for types that have overloaded &&. This fixes #574. --- include/internal/catch_capture.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index fa5835b8..902c6288 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -40,7 +40,8 @@ __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \ } \ INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look + } while( Catch::isTrue( false && static_cast( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look + // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \