diff --git a/include/fmt/compile.h b/include/fmt/compile.h index a97c0bdc..679da4f2 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -547,7 +547,7 @@ constexpr auto compile_format_string(S format_str) { return parse_tail(make_text(str, POS, end - POS), format_str); } else { - return parse_tail(code_unit{str[0]}, + return parse_tail(code_unit{str[POS]}, format_str); } } diff --git a/test/compile-test.cc b/test/compile-test.cc index a47cea54..c4d7ce74 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -162,5 +162,6 @@ TEST(CompileTest, FormatTo) { TEST(CompileTest, TextAndArg) { EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42)); + EXPECT_EQ("42!", fmt::format(FMT_COMPILE("{}!"), 42)); } #endif diff --git a/test/os-test.cc b/test/os-test.cc index 2d11c4c9..b1917f7e 100644 --- a/test/os-test.cc +++ b/test/os-test.cc @@ -81,7 +81,7 @@ TEST(UtilTest, FormatWindowsError) { EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), fmt::to_string(actual_message)); actual_message.resize(0); - auto max_size = fmt::detail::max_value(); + auto max_size = fmt::detail::max_value() / 2; fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, fmt::string_view(nullptr, max_size)); EXPECT_EQ(fmt::format("error {}", ERROR_FILE_EXISTS),