From ef581555b3092bfc0542dc5d15cab83c531a9260 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 31 Oct 2022 08:36:59 +0100 Subject: [PATCH] QProperty: only use MSVC bug workaround on MSVC The fix for QTBUG-106277 appears to cause issues with older gcc versions in C++2a mode (for instance used in our headers check). Thus, use the old code for all non-MSVC compilers, which never had problems with it. Fixes: QTBUG-108039 Change-Id: If6a0ce6e8f41e9dc752614557e96c555ca0fe75c Reviewed-by: Ulf Hermann (cherry picked from commit 62a2951795f117ff10a6d85bcff8d93a71fd58da) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qproperty.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 82ef16caba5..4968b29cee8 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -18,7 +18,16 @@ #if defined(__cpp_lib_source_location) #define QT_SOURCE_LOCATION_NAMESPACE std #define QT_PROPERTY_COLLECT_BINDING_LOCATION -#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation::fromStdSourceLocation(std::source_location::current()) +#if defined(Q_CC_MSVC) +/* MSVC runs into an issue with constexpr with source location (error C7595) + so use the factory function as a workaround */ +# define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation::fromStdSourceLocation(std::source_location::current()) +#else +/* some versions of gcc in turn run into + expression ‘std::source_location::current()’ is not a constant expression + so don't use the workaround there */ +# define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::source_location::current()) +#endif #endif #endif