Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/checkio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ void CheckIO::checkFormatString(const Token * const tok,
// Count printf/scanf parameters..
int numFunction = 0;
while (argListTok2) {
if (Token::Match(argListTok2, "%name% ...")) // bailout for parameter pack
return;
numFunction++;
argListTok2 = argListTok2->nextArgument(); // Find next argument
}
Expand Down
11 changes: 11 additions & 0 deletions test/testio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class TestIO : public TestFixture {
TEST_CASE(testPrintfAuto); // #8992
TEST_CASE(testPrintfParenthesis); // #8489
TEST_CASE(testStdDistance); // #10304
TEST_CASE(testParameterPack); // #11289
}

#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
Expand Down Expand Up @@ -4868,6 +4869,16 @@ class TestIO : public TestFixture {
"}", /*inconclusive*/ false, /*portability*/ true);
ASSERT_EQUALS("", errout.str());
}

void testParameterPack() { // #11289
check("template <typename... Args> auto f(const char* format, const Args&... args) {\n"
" return snprintf(nullptr, 0, format, args...);\n"
"}\n"
"void g() {\n"
" f(\"%d%d\", 1, 2);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};

REGISTER_TEST(TestIO)