From 2136406b4cac2e6db4786170cfa9be5372e27da7 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 20 Apr 2021 12:49:05 +0200 Subject: Work around MSVC compilation issue MSVC does not seem to instantiate code in the else branch of the constexpr if statement even though the condition is true. This causes an error if the PropertyType is void, as we then would attempt to create an object of type void. Work-around the issue by explicitly checking that the type is not void. Fixes: QTBUG-92962 Change-Id: Ie5acb6fae532bcc441be34418d4724de9d65b340 Reviewed-by: Ulf Hermann --- src/corelib/kernel/qpropertyprivate.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qpropertyprivate.h') diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index f59221c4df..5b6a9557f9 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -199,7 +199,7 @@ struct BindingFunctionVTable static_assert (std::is_invocable_r_v ); auto untypedEvaluationFunction = static_cast(f); return std::invoke(*untypedEvaluationFunction, metaType, dataPtr); - } else { + } else if constexpr (!std::is_same_v) { // check for void to woraround MSVC issue Q_UNUSED(metaType); QPropertyData *propertyPtr = static_cast *>(dataPtr); // That is allowed by POSIX even if Callable is a function pointer @@ -211,6 +211,10 @@ struct BindingFunctionVTable } propertyPtr->setValueBypassingBindings(std::move(newValue)); return true; + } else { + // Our code will never instantiate this + Q_UNREACHABLE(); + return false; } }, /*destroy*/[](void *f){ static_cast(f)->~Callable(); }, -- cgit v1.2.3