From ed65deafa7415c2f42cc94189c37c07115b86680 Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka Date: Fri, 27 Jan 2023 00:22:51 +0400 Subject: [PATCH] Fixed Visual Studio 2022: protobuf\src\google\protobuf\arena.cc(457,51): error C2127: 'thread_cache_': illegal initialization of 'constinit' entity with a non-constant expression #11672 --- src/google/protobuf/arena.cc | 2 +- src/google/protobuf/thread_safe_arena.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index b33e852c33..6ac4bab6c6 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -453,7 +453,7 @@ ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() { return thread_cache; } #else -PROTOBUF_THREAD_LOCAL +PROTOBUF_CONSTINIT PROTOBUF_THREAD_LOCAL ThreadSafeArena::ThreadCache ThreadSafeArena::thread_cache_; #endif diff --git a/src/google/protobuf/thread_safe_arena.h b/src/google/protobuf/thread_safe_arena.h index 885a564d1c..fa2be1b1cf 100644 --- a/src/google/protobuf/thread_safe_arena.h +++ b/src/google/protobuf/thread_safe_arena.h @@ -260,7 +260,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { // wrap them in static functions. static ThreadCache& thread_cache(); #else - static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_; + PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_; static ThreadCache& thread_cache() { return thread_cache_; } #endif