Skip to content

Commit 9d6e24c

Browse files
committed
Fix handling of long with FMT_BUILTIN_TYPES=0
1 parent 0843317 commit 9d6e24c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/fmt/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
FMT_PRAGMA_GCC(push_options)
240240
#if !defined(__OPTIMIZE__) && !defined(__CUDACC__) && !defined(FMT_MODULE)
241241
FMT_PRAGMA_GCC(optimize("Og"))
242-
#define FMT_GCC_OPTIMIZED
242+
# define FMT_GCC_OPTIMIZED
243243
#endif
244244
FMT_PRAGMA_CLANG(diagnostic push)
245245

@@ -1102,7 +1102,7 @@ FMT_CONSTEXPR void init_static_named_arg(named_arg_info<Char>* named_args,
11021102

11031103
// To minimize the number of types we need to deal with, long is translated
11041104
// either to int or to long long depending on its size.
1105-
enum { long_short = sizeof(long) == sizeof(int) };
1105+
enum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES };
11061106
using long_type = conditional_t<long_short, int, long long>;
11071107
using ulong_type = conditional_t<long_short, unsigned, unsigned long long>;
11081108

test/no-builtin-types-test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
TEST(no_builtin_types_test, format) {
1515
EXPECT_EQ(fmt::format("{}", 42), "42");
16+
EXPECT_EQ(fmt::format("{}", 42L), "42");
1617
}
1718

1819
TEST(no_builtin_types_test, double_is_custom_type) {

0 commit comments

Comments
 (0)