From 6a1346405949ca1cf5befc5e83c6c66c86e4f9d1 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 16 Feb 2022 15:28:16 -0800 Subject: [PATCH] Include 128-bit with other signed integers in specifier check --- include/fmt/core.h | 3 ++- test/format-test.cc | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 38fed451..d8baed9e 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2819,7 +2819,8 @@ template class specs_checker : public Handler { FMT_CONSTEXPR void on_sign(sign_t s) { require_numeric_argument(); if (is_integral_type(arg_type_) && arg_type_ != type::int_type && - arg_type_ != type::long_long_type && arg_type_ != type::char_type) { + arg_type_ != type::long_long_type && arg_type_ != type::int128_type && + arg_type_ != type::char_type) { this->on_error("format specifier requires signed argument"); } Handler::on_sign(s); diff --git a/test/format-test.cc b/test/format-test.cc index be8e5563..b63445ea 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -570,6 +570,9 @@ TEST(format_test, plus_sign) { EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), 42ul), format_error, "format specifier requires signed argument"); EXPECT_EQ("+42", fmt::format("{0:+}", 42ll)); +#if FMT_USE_INT128 + EXPECT_EQ("+42", fmt::format("{0:+}", __int128_t(42))); +#endif EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), 42ull), format_error, "format specifier requires signed argument"); EXPECT_EQ("+42", fmt::format("{0:+}", 42.0));