From 3f864a4505426ed19e5ba55261af37669a123e4c Mon Sep 17 00:00:00 2001 From: Edoardo Lolletti Date: Wed, 8 Jan 2025 23:21:48 +0100 Subject: [PATCH] Address MSVC C4127 warning when formatting non unicode `tm` (#4299) Use `const_check` to silence visual studio's W4 level diagnostic regarding conditional expressions being constants, addresses https://github.com/fmtlib/fmt/issues/4294 --- include/fmt/chrono.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index abf3671e5b59..76bbb909058b 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -364,7 +364,7 @@ void write_codecvt(codecvt_result& out, string_view in, template auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc) -> OutputIt { - if (detail::use_utf8 && loc != get_classic_locale()) { + if (const_check(detail::use_utf8) && loc != get_classic_locale()) { // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and // gcc-4. #if FMT_MSC_VERSION != 0 || \