From 8564f72e8e0334c25c480e0aec1df75bdc1fce14 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Jun 2024 13:18:03 -0700 Subject: [PATCH] [omg] Avoid MSVC miscompile (#36893) Seems MSVC has trouble compiling this statically initialized lambda in a template; crash goes away when I split it out to be a named function instead. Closes #36893 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36893 from ctiller:edward 4bf9b88797abb214f83996c9fb405cbabbfa7e96 PiperOrigin-RevId: 642714465 --- src/core/lib/resource_quota/arena.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/lib/resource_quota/arena.h b/src/core/lib/resource_quota/arena.h index 916dbec4548..5d282e57a4d 100644 --- a/src/core/lib/resource_quota/arena.h +++ b/src/core/lib/resource_quota/arena.h @@ -94,8 +94,13 @@ class ArenaContextTraits : public BaseArenaContextTraits { }; template -const uint16_t ArenaContextTraits::id_ = BaseArenaContextTraits::MakeId( - [](void* ptr) { ArenaContextType::Destroy(static_cast(ptr)); }); +void DestroyArenaContext(void* p) { + ArenaContextType::Destroy(static_cast(p)); +} + +template +const uint16_t ArenaContextTraits::id_ = + BaseArenaContextTraits::MakeId(DestroyArenaContext); template struct IfArray { @@ -283,6 +288,7 @@ class Arena final : public RefCounted::Destroy(static_cast(slot)); } slot = context; + DCHECK_EQ(GetContext(), context); } private: