diff --git a/include/fmt/core.h b/include/fmt/core.h index 8848939f..6e658021 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2694,7 +2694,7 @@ struct formatter \ struct formatter : formatter { \ template \ - auto format(const Type& val, FormatContext& ctx) const \ + auto format(Type const& val, FormatContext& ctx) const \ -> decltype(ctx.out()) { \ return formatter::format(static_cast(val), ctx); \ } \ diff --git a/test/format-test.cc b/test/format-test.cc index 6150e433..638bd143 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2245,3 +2245,19 @@ TEST(format_test, format_named_arg_with_locale) { } #endif // FMT_STATIC_THOUSANDS_SEPARATOR + +struct convertible_to_nonconst_cstring { + operator char*() const { + static char c[]="bar"; + return c; + } +}; + +FMT_BEGIN_NAMESPACE +template <> struct formatter : formatter { +}; +FMT_END_NAMESPACE + +TEST(format_test, formatter_nonconst_char) { + EXPECT_EQ(fmt::format("{}", convertible_to_nonconst_cstring()), "bar"); +}