mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 19:24:48 +02:00
Workaround a gcc 10 -Warray-bounds bug (#2065)
This commit is contained in:
@@ -3221,7 +3221,8 @@ class format_string_checker {
|
|||||||
FMT_CONSTEXPR const Char* on_format_specs(int id, const Char* begin,
|
FMT_CONSTEXPR const Char* on_format_specs(int id, const Char* begin,
|
||||||
const Char*) {
|
const Char*) {
|
||||||
advance_to(context_, begin);
|
advance_to(context_, begin);
|
||||||
return id < num_args ? parse_funcs_[id](context_) : begin;
|
// id >= 0 check is a workaround for gcc 10 bug (#2065).
|
||||||
|
return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_error(const char* message) {
|
FMT_CONSTEXPR void on_error(const char* message) {
|
||||||
|
@@ -1822,6 +1822,7 @@ static FMT_CONSTEXPR_DECL const char static_no_null[2] = {'{', '}'};
|
|||||||
static FMT_CONSTEXPR_DECL const wchar_t static_no_null_wide[2] = {'{', '}'};
|
static FMT_CONSTEXPR_DECL const wchar_t static_no_null_wide[2] = {'{', '}'};
|
||||||
|
|
||||||
TEST(FormatTest, CompileTimeString) {
|
TEST(FormatTest, CompileTimeString) {
|
||||||
|
EXPECT_EQ("foo", fmt::format(FMT_STRING("foo")));
|
||||||
EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), 42));
|
EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), 42));
|
||||||
EXPECT_EQ(L"42", fmt::format(FMT_STRING(L"{}"), 42));
|
EXPECT_EQ(L"42", fmt::format(FMT_STRING(L"{}"), 42));
|
||||||
EXPECT_EQ("foo", fmt::format(FMT_STRING("{}"), string_like()));
|
EXPECT_EQ("foo", fmt::format(FMT_STRING("{}"), string_like()));
|
||||||
|
Reference in New Issue
Block a user