From 3fc53eb12203bb85d00b84bc9ddfb362c143d70a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 10 Apr 2018 21:07:39 +0200 Subject: [PATCH] std.cfg: Add std::[w]string::compare() with tests (#1162) --- cfg/std.cfg | 32 ++++++++++++++++++++++++++++++++ test/cfg/std.cpp | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index ab155d205..c51fd9807 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6090,6 +6090,38 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + false diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 782455034..102699f6b 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -3019,6 +3019,17 @@ void uninivar_istream_read(std::istream &f) f.read(buffer, size); } +void uninitvar_string_compare(std::string &teststr, std::wstring &testwstr) +{ + char *pStrUninit; + // cppcheck-suppress uninitvar + (void)teststr.compare(pStrUninit); + + wchar_t *pWStrUninit; + // cppcheck-suppress uninitvar + (void)testwstr.compare(pWStrUninit); +} + void invalidFunctionArgBool_abs(bool b, double x, double y) { // cppcheck-suppress invalidFunctionArgBool @@ -3037,6 +3048,14 @@ void ignoredReturnValue_abs(int i) std::abs(-199); } +void ignoredReturnValue_string_compare(std::string teststr, std::wstring testwstr) +{ + // cppcheck-suppress ignoredReturnValue + teststr.compare("test"); + // cppcheck-suppress ignoredReturnValue + testwstr.compare(L"wtest"); +} + void nullPointer_ifstream_read(std::ifstream &f) { // cppcheck-suppress nullPointer