From 958845891726ed011eb9a0fc1b2db9dd9989049a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Ljungstr=C3=B6m?= Date: Sun, 17 Aug 2025 18:35:28 +0200 Subject: [PATCH] Silence unreachable code warnings in MSVC when FMT_USE_EXCEPTIONS are disabled. (#4515) --- include/fmt/format-inl.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index af9480f8..aaa3eaef 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -138,8 +138,12 @@ FMT_FUNC void report_error(const char* message) { // from MSVC. FMT_THROW(format_error(message)); #else - fputs(message, stderr); - abort(); + // Silence unreachable code warnings in MSVC. + volatile bool b = true; + if (b) { + fputs(message, stderr); + abort(); + } #endif }