From 73b9442edd8c7a2c60d7c97e60fe86522d49af77 Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Wed, 23 Aug 2023 10:33:01 +0200 Subject: [PATCH] Fix constParameterPointer regression (#5361) Commit 73251544a ("Fix #11842 FN constParameterPointer with library function (#5257)") most likely introduced a regression for (C) function pointers passed to functions provided by the standard library that cppcheck has knowledge about. --- cfg/std.cfg | 2 +- test/testother.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 0acf4a3ce..278bbd871 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4445,7 +4445,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun 0: - + diff --git a/test/testother.cpp b/test/testother.cpp index ecf9d9837..4f5782e6d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3808,6 +3808,11 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'p' can be declared as pointer to const\n", errout.str()); + + check("void f(void *p, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) {\n" + " qsort(p, nmemb, size, cmp);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void switchRedundantAssignmentTest() {