diff --git a/include/fmt/core.h b/include/fmt/core.h index 2fcaf845..b19abf37 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2429,6 +2429,7 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( case 'G': return parse_presentation_type(pres::general_upper, float_set); case 'c': + if (arg_type == type::bool_type) throw_format_error("invalid format specifier"); return parse_presentation_type(pres::chr, integral_set); case 's': return parse_presentation_type(pres::string, diff --git a/test/format-test.cc b/test/format-test.cc index 34eb28a3..0a9924bf 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1159,6 +1159,8 @@ TEST(format_test, format_bool) { EXPECT_EQ("true", fmt::format("{:s}", true)); EXPECT_EQ("false", fmt::format("{:s}", false)); EXPECT_EQ("false ", fmt::format("{:6s}", false)); + EXPECT_THROW_MSG((void)fmt::format(runtime("{:c}"), false), format_error, + "invalid format specifier"); } TEST(format_test, format_short) {