From 70aa27ed70990be6ea86d47390f200154a477c49 Mon Sep 17 00:00:00 2001 From: Sergey Khalyutn Date: Tue, 2 Jun 2026 14:09:33 +0300 Subject: [PATCH 1/2] Fix: The compiler does not consider "#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)" as a constant - compilation error: constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression ``` [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] /code/src/remote\../remote\../common/ThreadStart.h:77:26: error: constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] | ^ ~~~~~~~~~~~~~~~~~~~~ [build] /code/src/remote\../remote\../common/ThreadStart.h:77:43: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] | ^ [build] C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\handleapi.h:27:31: note: expanded from macro 'INVALID_HANDLE_VALUE' [build] 27 | #define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1) [build] | ^ ``` --- src/common/ThreadStart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ThreadStart.h b/src/common/ThreadStart.h index 40412735e4f..e92e2939997 100644 --- a/src/common/ThreadStart.h +++ b/src/common/ThreadStart.h @@ -74,7 +74,7 @@ class Thread public: #ifdef WIN_NT typedef HANDLE Handle; - constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; + inline static const Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; #endif #ifdef USE_POSIX_THREADS typedef pthread_t Handle; From ff8137942e879c69f61476d581704b0cf29a59ca Mon Sep 17 00:00:00 2001 From: Sergey Khalyutn <124491821+Khalyutin@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:37:38 +0300 Subject: [PATCH 2/2] Add comment about "constexpr" not applicable in case --- src/common/ThreadStart.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/ThreadStart.h b/src/common/ThreadStart.h index e92e2939997..3f5970bbcc3 100644 --- a/src/common/ThreadStart.h +++ b/src/common/ThreadStart.h @@ -74,6 +74,14 @@ class Thread public: #ifdef WIN_NT typedef HANDLE Handle; + /* + * "constexpr" not applicable for Handle INVALID_HANDLE = INVALID_HANDLE_VALUE + * because in Windows INVALID_HANDLE_VALUE define in handleapi.h as: + * "#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)" + * but C-cast & reinterpret_cast<>() are prohibited in constexpr. + * The Clang++ compiler does not consider it`s as a constant expression and raise compilation error: + * "constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression" + */ inline static const Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; #endif #ifdef USE_POSIX_THREADS