From 9d6e24c64e41cfdf24cc2815145d87da1356349a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 22 Mar 2025 07:33:28 -0700 Subject: [PATCH] Fix handling of long with FMT_BUILTIN_TYPES=0 --- include/fmt/base.h | 4 ++-- test/no-builtin-types-test.cc | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index c6fc1d09..57e17bba 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -239,7 +239,7 @@ FMT_PRAGMA_GCC(push_options) #if !defined(__OPTIMIZE__) && !defined(__CUDACC__) && !defined(FMT_MODULE) FMT_PRAGMA_GCC(optimize("Og")) -#define FMT_GCC_OPTIMIZED +# define FMT_GCC_OPTIMIZED #endif FMT_PRAGMA_CLANG(diagnostic push) @@ -1102,7 +1102,7 @@ FMT_CONSTEXPR void init_static_named_arg(named_arg_info* named_args, // To minimize the number of types we need to deal with, long is translated // either to int or to long long depending on its size. -enum { long_short = sizeof(long) == sizeof(int) }; +enum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES }; using long_type = conditional_t; using ulong_type = conditional_t; diff --git a/test/no-builtin-types-test.cc b/test/no-builtin-types-test.cc index fd15d002..a0d0bda3 100644 --- a/test/no-builtin-types-test.cc +++ b/test/no-builtin-types-test.cc @@ -13,6 +13,7 @@ TEST(no_builtin_types_test, format) { EXPECT_EQ(fmt::format("{}", 42), "42"); + EXPECT_EQ(fmt::format("{}", 42L), "42"); } TEST(no_builtin_types_test, double_is_custom_type) {