scanf with %zd expects ssize_t, not ptrdiff_t

This commit is contained in:
Dmitry-Me 2017-10-24 22:01:23 +03:00
parent 709ee6e278
commit eaa12db761
2 changed files with 3 additions and 3 deletions

View File

@ -1852,7 +1852,7 @@ void CheckIO::invalidScanfArgTypeError_int(const Token* tok, unsigned int numFor
errmsg << "intmax_t"; errmsg << "intmax_t";
} else if (specifier[0] == 'z') { } else if (specifier[0] == 'z') {
if (specifier[1] == 'd') if (specifier[1] == 'd')
errmsg << "ptrdiff_t"; errmsg << "ssize_t";
else else
errmsg << "size_t"; errmsg << "size_t";
} else if (specifier[0] == 't') { } else if (specifier[0] == 't') {

View File

@ -1702,8 +1702,8 @@ private:
" scanf(\"%zd\", &s2);\n" " scanf(\"%zd\", &s2);\n"
" scanf(\"%zd\", &s3);\n" " scanf(\"%zd\", &s3);\n"
"}\n"; "}\n";
const char* result("[test.cpp:5]: (portability) %zd in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n"); const char* result("[test.cpp:5]: (portability) %zd in format string (no. 1) requires 'ssize_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n");
const char* result_win64("[test.cpp:5]: (portability) %zd in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n"); const char* result_win64("[test.cpp:5]: (portability) %zd in format string (no. 1) requires 'ssize_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n");
check(code, false, true, Settings::Unix32); check(code, false, true, Settings::Unix32);
ASSERT_EQUALS(result, errout.str()); ASSERT_EQUALS(result, errout.str());