diff --git a/cfg/std.cfg b/cfg/std.cfg index 425575e04..b65039679 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -7204,7 +7204,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init - + false diff --git a/test/testio.cpp b/test/testio.cpp index a96b07e76..d37bfad54 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -74,6 +74,7 @@ private: TEST_CASE(testPrintfTypeAlias1); TEST_CASE(testPrintfAuto); // #8992 TEST_CASE(testPrintfParenthesis); // #8489 + TEST_CASE(testStdDistance); // #10304 } void check(const char* code, bool inconclusive = false, bool portability = false, Settings::PlatformType platform = Settings::Unspecified, bool onlyFormatStr = false) { @@ -4819,6 +4820,14 @@ private: "}"); ASSERT_EQUALS("[test.cpp:2]: (warning) %f in format string (no. 1) requires 'double' but the argument type is 'signed int'.\n", errout.str()); } + + void testStdDistance() { // #10304 + check("void foo(const std::vector& IO, const int* pio) {\n" + "const auto Idx = std::distance(&IO.front(), pio);\n" + "printf(\"Idx = %td\", Idx);\n" + "}", /*inconclusive*/ false, /*portability*/ true); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestIO)