From b17b8802b86b8af01087ea4cd03da05eea1b5a00 Mon Sep 17 00:00:00 2001 From: Deniz Evrenci Date: Thu, 9 Nov 2023 04:52:17 -0800 Subject: [PATCH] Constexpr check for AsyncGenerator's cleanup Summary: With MSVC 19.35 C++20 /O2, the check spuriously fails. As this is a template parameter, the check can be lifted to the compile time for the particular type. This seems to mitigate the spurious failures. Reviewed By: Orvid, michalkielan Differential Revision: D51098782 fbshipit-source-id: c36a1d201c6e51a19ac2a7b0737941ccb79e614d --- folly/experimental/coro/AsyncGenerator.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/folly/experimental/coro/AsyncGenerator.h b/folly/experimental/coro/AsyncGenerator.h index 9e624eaebf2..656936b12fa 100644 --- a/folly/experimental/coro/AsyncGenerator.h +++ b/folly/experimental/coro/AsyncGenerator.h @@ -178,7 +178,10 @@ class FOLLY_NODISCARD AsyncGenerator { ~AsyncGenerator() { if (coro_) { - CHECK(!RequiresCleanup) << "cleanup() hasn't been called!"; + if constexpr (RequiresCleanup) { + LOG(FATAL) << "cleanup() hasn't been called!"; + } + coro_.destroy(); } }