diff --git a/format.cc b/format.cc index 519b072a..229fcea7 100644 --- a/format.cc +++ b/format.cc @@ -233,11 +233,12 @@ class ArgConverter : public fmt::internal::ArgVisitor, void> { } else { if (is_signed) { arg_.type = Arg::LONG_LONG; - arg_.long_long_value = static_cast(value); + arg_.long_long_value = + static_cast::Type>(value); } else { arg_.type = Arg::ULONG_LONG; arg_.ulong_long_value = - static_cast::Type>(value); + static_cast::Type>(value); } } } @@ -906,10 +907,6 @@ void fmt::internal::PrintfFormatter::format( } // Parse length and convert the argument to the required type. - // Conversion is done for compatibility with glibc's printf, MSVC's - // printf simply ignores width specifiers. For example: - // printf("%hhd", -129); - // prints 127 when using glibc's printf and -129 when using MSVC's one. switch (*s) { case 'h': { ++s; diff --git a/test/printf-test.cc b/test/printf-test.cc index 95db8094..08bfc28a 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -308,6 +308,8 @@ void TestLength(const char *length_spec) { EXPECT_STD_PRINTF(format, T, max); EXPECT_STD_PRINTF(format, T, fmt::LongLong(min) - 1); EXPECT_STD_PRINTF(format, T, fmt::LongLong(max) + 1); + EXPECT_STD_PRINTF(format, T, std::numeric_limits::min()); + EXPECT_STD_PRINTF(format, T, std::numeric_limits::max()); EXPECT_STD_PRINTF(format, T, std::numeric_limits::min()); EXPECT_STD_PRINTF(format, T, std::numeric_limits::max()); EXPECT_STD_PRINTF(format, T, std::numeric_limits::min()); @@ -320,12 +322,12 @@ void TestLength(const char *length_spec) { } TEST(PrintfTest, Length) { - TestLength("h"); - TestLength("h"); TestLength("hh"); TestLength("hh"); - //TestLength("l"); - //TestLength("l"); + TestLength("h"); + TestLength("h"); + TestLength("l"); + TestLength("l"); // TODO: more tests }