diff --git a/include/fmt/core.h b/include/fmt/core.h index 8cdc9cdcb81d..c6f771902d0e 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1208,6 +1208,7 @@ template class basic_format_args { format_arg do_get(int index) const { format_arg arg; + if (index < 0) return arg; if (!is_packed()) { auto num_args = max_size(); if (index < num_args) arg = args_[index]; diff --git a/test/core-test.cc b/test/core-test.cc index 84d2b9eb0172..76612b9914db 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -103,7 +103,7 @@ template struct mock_buffer : buffer { TEST(BufferTest, Ctor) { { mock_buffer buffer; - EXPECT_EQ(nullptr, &buffer[0]); + EXPECT_EQ(nullptr, buffer.data()); EXPECT_EQ(static_cast(0), buffer.size()); EXPECT_EQ(static_cast(0), buffer.capacity()); } diff --git a/test/printf-test.cc b/test/printf-test.cc index cd9950d170b0..d8fbc9649aec 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -337,7 +337,9 @@ template void TestLength(const char* length_spec) { TestLength(length_spec, -42); TestLength(length_spec, min); TestLength(length_spec, max); - TestLength(length_spec, static_cast(min) - 1); + long long long_long_min = std::numeric_limits::min(); + if (static_cast(min) > long_long_min) + TestLength(length_spec, static_cast(min) - 1); unsigned long long long_long_max = max_value(); if (static_cast(max) < long_long_max) TestLength(length_spec, static_cast(max) + 1);