diff --git a/lib/checkio.cpp b/lib/checkio.cpp index b72c4763c..ef8407a7a 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1782,7 +1782,7 @@ void CheckIO::invalidScanfArgTypeError_int(const Token* tok, nonneg int numForma else errmsg << "intmax_t"; } else if (specifier[0] == 'z') { - if (specifier[1] == 'd') + if (specifier[1] == 'd' || specifier[1] == 'i') errmsg << "ssize_t"; else errmsg << "size_t"; @@ -1875,7 +1875,7 @@ static void printfFormatType(std::ostream& os, const std::string& specifier, boo else os << "intmax_t"; } else if (specifier[0] == 'z') { - if (specifier[1] == 'd') + if (specifier[1] == 'd' || specifier[1] == 'i') os << "ssize_t"; else os << "size_t"; diff --git a/test/testio.cpp b/test/testio.cpp index d94e3009a..e13e50d38 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -1533,6 +1533,8 @@ private: TEST_SCANF_NOWARN("%zd", "ssize_t", "ssize_t"); TEST_SCANF_WARN_AKA("%zd", "ssize_t", "ptrdiff_t", "signed long", "signed long long"); + TEST_SCANF_WARN_AKA("%zi", "ssize_t", "size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "bool"); TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "char"); TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "signed char"); @@ -3705,6 +3707,9 @@ private: TEST_PRINTF_WARN_AKA("%jx", "uintmax_t", "std::intptr_t", "signed long", "signed long long"); TEST_PRINTF_WARN_AKA("%jx", "uintmax_t", "std::uintptr_t", "unsigned long", "unsigned long long"); + TEST_PRINTF_WARN_AKA("%zd", "ssize_t", "size_t", "unsigned long", "unsigned long long"); + TEST_PRINTF_WARN_AKA("%zi", "ssize_t", "size_t", "unsigned long", "unsigned long long"); + TEST_PRINTF_WARN("%zu", "size_t", "bool"); TEST_PRINTF_WARN("%zu", "size_t", "char"); TEST_PRINTF_WARN("%zu", "size_t", "signed char");