From c4b6db7e2335a2b1e53c86fb1420533b45c0c3fa Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 20 Nov 2017 22:13:20 +0300 Subject: [PATCH] Fix FP for std::uintmax_t passed as %ju and %jx into scanf --- lib/checkio.cpp | 2 +- test/testio.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 5b0860f2a..c60008c9d 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -768,7 +768,7 @@ void CheckIO::checkFormatString(const Token * const tok, invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); break; case 'j': - if (argInfo.typeToken->originalName() != "uintmax_t") + if (!typesMatch(argInfo.typeToken->originalName(), "uintmax_t")) invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); break; case 'z': diff --git a/test/testio.cpp b/test/testio.cpp index 7b7b1549b..2751bbf5a 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -1413,6 +1413,7 @@ private: TEST_SCANF_WARN_AKA("%ju", "uintmax_t", "std::size_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%ju", "uintmax_t", "std::ssize_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%ju", "uintmax_t", "std::ptrdiff_t", "signed long", "signed long long"); + TEST_SCANF_NOWARN("%ju", "uintmax_t", "std::uintmax_t"); TEST_SCANF_WARN_AKA("%ju", "uintmax_t", "std::intptr_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%ju", "uintmax_t", "std::uintptr_t", "unsigned long", "unsigned long long"); @@ -1441,6 +1442,7 @@ private: TEST_SCANF_WARN_AKA("%jx", "uintmax_t", "std::size_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%jx", "uintmax_t", "std::ssize_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%jx", "uintmax_t", "std::ptrdiff_t", "signed long", "signed long long"); + TEST_SCANF_NOWARN("%jx", "uintmax_t", "std::uintmax_t"); TEST_SCANF_WARN_AKA("%jx", "uintmax_t", "std::intptr_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%jx", "uintmax_t", "std::uintptr_t", "unsigned long", "unsigned long long");