diff --git a/cfg/std.cfg b/cfg/std.cfg index f704dafc0..ea6be2cc7 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6813,6 +6813,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + 0: @@ -6825,6 +6826,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + 0: @@ -6837,6 +6839,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + 0: diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 3e06bd92a..84f0a37e7 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -31,6 +31,26 @@ #include #include +void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) { + // cppcheck-suppress invalidFunctionArg + (void)str.substr(-1,len); + // cppcheck-suppress invalidFunctionArg + (void)str.substr(pos,-1); + // no warning is expected for + (void)str.substr(pos,len); + (void)str.substr(pos, std::wstring::npos); +} + +void invalidFunctionArg_std_wstring_substr(const std::wstring &str, std::size_t pos, std::size_t len) { + // cppcheck-suppress invalidFunctionArg + (void)str.substr(-1,len); + // cppcheck-suppress invalidFunctionArg + (void)str.substr(pos,-1); + // no warning is expected for + (void)str.substr(pos,len); + (void)str.substr(pos, std::string::npos); +} + double invalidFunctionArg_log10(double d = 0.0) { // cppcheck-suppress invalidFunctionArg return log10(d);