From fa8199459dbccfe2f6c8042d91406dafaabc97d3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 21 Mar 2024 10:52:47 +0100 Subject: [PATCH] QVariant: fix C++20 build with older MSVC 2022 ... which claim full C++20 conformance (__cplusplus >= 202002), but still lack https://wg21.link/P0846. Fix by extending the existing workaround for lack of P0846 support to these compilers. Known to fail: _MSC_VER 1936 Known to pass: _MSC_VER 1939 We might need to check 1938 and 1937, but the workaround should only show up as an additional get/get_if overload and not disturb normal operation, so it's not critical to get the boundary version exactly right. Amends eb9c8042cfa71f16cda27cdeb052d84a6cc117d7. Task-number: QTQAINFRA-6204 Change-Id: Ia3e0072d606efb7efd6ce0f75239850c7cd925bb Reviewed-by: Oliver Wolff (cherry picked from commit ab06d402dd833cefe9c0d929c13e93068aab96d9) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qcompilerdetection.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 0230b5a7844..b2340bff8ec 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1406,7 +1406,11 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic #endif #if defined(__cplusplus) && __cplusplus >= 202002L // P0846 doesn't have a feature macro :/ +# if !defined(Q_CC_MSVC_ONLY) || Q_CC_MSVC < 1939 // claims C++20 support but lacks P0846 + // 1939 is known to work + // 1936 is known to fail # define QT_COMPILER_HAS_P0846 +# endif #endif #ifdef QT_COMPILER_HAS_P0846