I found that cppcheck’s addon dump can produce MISRA diagnostics in a non-source order. In SymbolDatabase::printXml() (lib/symboldatabase.cpp), variables are collected in std::set<const Variable*> before the <variables> XML section is written. This orders records by object-pointer address instead of a stable source key. The MISRA addon reads that XML order into data.variables, and Rule 9.3 then iterates data.variables directly. Therefore Rule 9.3 diagnostics can be reported in a different order from...
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15103
Found in cppcheck 2.22 Running cppcheck --enable=style --std=c++17 --template=gcc repro.cpp on #include <functional> #include <vector> struct Item {}; void example() { Item value; auto& ref = value; std::vector<std::reference_wrapper<Item>> refs{ref}; } gives Variable 'ref' can be declared as reference to const [constVariableReference]
Depending on how many tokens you want to use here are other things you can ask AI about a PR. Will this PR require the cppcheck manual to change? if yes which sections. What unit test cover these changes? if no unit test is found can please write one. What do you think the intent of this PR is?
To me this talk has lived rent free in my brain since 2012 https://youtu.be/5wwKjdvPxa8 its about how CI can be used as a code reviewer. Most CI systems are pass fail. But there tea leaves that often go unnoticed. I think in the age of AI its probably a good idea to use AI as a first pass aproach to keep from getting overwhelmed. I even know of an open source project that is talking internally about poising their skill file to say all issues must be written using Shakespearen English. That way they...
Please provide feedback. Do you think I should tweak the reports or output somehow? Having a link to the actual PR would be nice (instead of/additional to linking to the AWS files). How is reanalysis supposed to work? E.g. for #8918, the latest commit shown is from Oct 5, while there is a newer commit from Oct 7 already (https://github.com/cppcheck-opensource/cppcheck/pull/8918/changes/97161058bc8dbc7b18acf69ae1cf324a21507f65).
I think one thing that matters a lot is how easy is it for you to integrate into your workflow. For me given that I learned to code inside a unix terminal and never evolved to using an IDE to code with AI isnt to difficult to record my interactions with. The script command https://www.redhat.com/en/blog/linux-script-command does alot of the heavy lifting. I also write a bit of data like starting and stopping git hash as well as the ai model version and token usage to a file. That way I can restore...
One thing I recomend when it comes to AI is to keep internal metrics so that you can better help you evluete AI future solutions how do you suggest that I do that?
One thing I recomend when it comes to AI is to keep internal metrics so that you can better help you evluete AI future solutions. That includes keeping track of the work done by AI which you can put a tag in an issue or a tag in the git commit message. You will want to be able to match that tag to a prompt, token usage and model version number. That way if you want to make changes later to your AI process you can test it aginst past solutions to see if the change adds value. On a side note one thing...
Good idea 👍 Having the user name in a column would be nice. Also, some PRs seem to be missing. Are they still being processed?
I am adding AI reviews in opensource cppcheck AI is not perfect there is some bad review comments. As a PR author you can reject such comments by resolving them. My idea going forward is that I will not review a PR manually if there are open AI reviews. I want to limit the amount of manual reviews because; for reviewers it takes a lot of time. I don't want to waste time on nits that we could avoid automatically. I have to re-review the whole PR every time I see some nits. for developers manual reviews...
It's still being processed. If we will have trouble to keep up with open PRs I think we can launch more runner VMs. It might be low with 100/1000 .. I will see if it makes sense to increase these values later. At least if a runner is idle it could fill up more packages..
Good idea 🆙 Having the user name in a column would be nice. Also, some PRs seem to be missing. Are they still being processed?
Good idea 🆙 Having the user name in a column would be nice.
I am experimenting with a webserver that will execute the test-my-pr script on PRs. I want more or less that it will provide daca@home feedback directly when somebody works on a PR. http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/ It is only executed on open non-draft PRs that have a successful CI. It will execute on 1000 packages if the PR modifies tokenizer or valueflow. Otherwise it will execute on 100 packages. When I started it , it would count packages even if they did not have C/C++...
I am experimenting with a webserver that will execute the test-my-pr script on PRs: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/ It will execute on 1000 packages if the PR modifies tokenizer or valueflow. Otherwise it will execute on 100 packages. When I started it , it would count packages even if they did not have C/C++ code that is fixed now.. AI-generated verdicts will be provided for a random subset of the warnings (up to 20 or so). Those should be taken with a grain of salt for...
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15089
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15088
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15087
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15086
I see a false positive running cppcheck 2.22.0 against the following code. Note the parameter cannot be declared as reference to const because its job is to match both const and mutable references, and return a reference to a member which retains the const-ness of the first argument (similar to the 'deduce this' pattern). The static asserts demonstrate the intended use cases. Note also that the false positive goes away if the concept is inlined as a template requires clause on the function itself...
I see a false positive running cppcheck 2.22.0 against the following code. Note the function itself cannot be static because it's an explicit member function (deducing this). #include <array> #include <cstddef> #include <ranges> #include <span> constexpr std::size_t GridSize{19}; class board { public: auto rows(this auto&& self) { auto* cells = self.data.data(); return std::views::iota(0zu, GridSize) | std::views::transform([cells](std::size_t row) { return std::span{cells + row * GridSize, GridSize};...
We've had this issue for many releases so can't provide a version that it started Running cppcheck --std=c++20 --enable=style,warning --template=gcc repro.cpp on namespace Legacy { struct Base { int Count() const; virtual void Print() const; virtual ~Base() = default; }; struct Position : Base { }; } using namespace Legacy; namespace Modern { struct Position { int Count() const; void Print() const; }; } gives repro.cpp:21:7: warning: The struct 'Position' defines member function with name 'Count'...
We've had this issue for many releases so can't provide a version that it started Running cppcheck --std=c++20 --enable=style,warning --template=gcc repro.cpp on namespace Legacy { struct Base { int Count() const; virtual void Print() const; virtual ~Base() = default; }; struct Position : Base { }; } using namespace Legacy; namespace Modern { struct Position { int Count() const; void Print() const; }; } gives repro.cpp:21:7: warning: The struct 'Position' defines member function with name 'Count'...
Reduced: struct S { bool f() const; int g() const; int x, y; }; bool S::f() const { const bool b = x ? g() < 0 : 0 > y; return b; }
Came in when upgrading from 2.21 to 2.22 Running cppcheck --std=c++20 --template=gcc on #include <algorithm> #include <vector> struct Box { float xMin, yMin, xMax, yMax; float Height() const { return yMax - yMin; } }; struct Processor { std::vector<Box> Update(const std::vector<Box>& input, int begin, int end) const; }; std::vector<Box> Processor::Update(const std::vector<Box>& input, int begin, int end) const { std::vector<Box> output; const auto visit = [&](int first, int last) { for (const auto&...
Came in when upgrading from 2.21 to 2.22 Running cppcheck --std=c++20 --template=gcc on #include <algorithm> #include <vector> struct Box { float xMin, yMin, xMax, yMax; float Height() const { return yMax - yMin; } }; struct Processor { std::vector<Box> Update(const std::vector<Box>& input, int begin, int end) const; }; std::vector<Box> Processor::Update(const std::vector<Box>& input, int begin, int end) const { std::vector<Box> output; const auto visit = [&](int first, int last) { for (const auto&...
Came in when upgrading from 2.21 to 2.22 Running cppcheck --std=c++20 --template=gcc --error-exitcode=2 repro.cpp on #include <algorithm> #include <vector> struct Box { float xMin, yMin, xMax, yMax; float Height() const { return yMax - yMin; } }; struct Processor { std::vector<Box> Update(const std::vector<Box>& input, int begin, int end) const; }; std::vector<Box> Processor::Update(const std::vector<Box>& input, int begin, int end) const { std::vector<Box> output; const auto visit = [&](int first,...
Came in when upgrading from 2.21 to 2.22 Running cppcheck --std=c++20 --template=gcc --error-exitcode=2 repro.cpp on #include <algorithm> #include <vector> struct Box { float xMin, yMin, xMax, yMax; float Height() const { return yMax - yMin; } }; struct Processor { std::vector<Box> Update(const std::vector<Box>& input, int begin, int end) const; }; std::vector<Box> Processor::Update(const std::vector<Box>& input, int begin, int end) const { std::vector<Box> output; const auto visit = [&](int first,...
i got this error and point to first { open braces when i use this code in my sources cppcheck run this check from myproject.cppcheck but i have no any error when i check this file or dir with my sources
i got this error and point to first { open braces when i use this code in my sources cppcheck run this check from myproject.cppcheck but i have no any error when i just this file
i got this error and point to { open braces when i use this code in my sources cppcheck run this check from myproject.cppcheck but i have no any error when i just this file
Hello, I found a preprocessing cache issue and have prepared a fix and regression test locally. Could a team member please create a Trac ticket so I can reference it in a pull request? Issue With --cppcheck-build-dir, unchanged input can be analyzed again on the immediate second run because the preprocessing hash depends on header load order. I reproduced this on commit fa6c1f1327057cb8ad4764df236daf6d3c70e359, using Windows x64 and an MSVC 2022 Debug build. Minimal reproduction Create these three...
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15076
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15075
See https://trac.cppcheck.net/ticket/14677
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15074
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15073
Looks like a special case of https://trac.cppcheck.net/ticket/1606
See https://trac.cppcheck.net/ticket/9921 and others.
See https://trac.cppcheck.net/ticket/2853
See https://trac.cppcheck.net/ticket/10201
Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when the array is accessed through a pointer alias. int a[2]; void f() { int *p = a; p[2] = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing p[2] = 0 with a[2] = 0 produces the warning. Expected result Cppcheck should report the out-of-bounds write through the alias. Verification The issue was reproduced with: cppcheck --output-format=xmlv2 --enable=all array_alias.cpp...
Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when the array expression is written as the address of its first element. int a[2]; void f() { (&a[0])[2] = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing (&a[0])[2] = 0 with a[2] = 0 produces the warning. The form ((int *)a)[2] = 0 is also missed. Expected result Cppcheck should report the out-of-bounds write in these equivalent subscript forms. Verification...
Hi, I found a false negative regarding the rule resourceLeak. Cppcheck misses the resource leak when the null check uses a local alias of the file pointer. #include <cstdio> int f() { const FILE *a = fopen("input.txt", "r"); const FILE *b = a; if (!b) return 0; return 0; } Actual result Cppcheck does not report resourceLeak. Removing b and changing the condition to if (!a) produces the warning. Expected result Cppcheck should report the missing fclose in both forms. Verification The issue was reproduced...
Hi, I found a false negative regarding the rule memleak. Cppcheck misses the leak when the allocated buffer is accessed through a pointer-to-pointer alias. #include <stdlib.h> int f(void) { int result = 0; char *a = malloc(10); char **b = &a; if (*b) { (*b)[0] = 0; result = (*b)[0]; } return result; } Actual result Cppcheck does not report memleak. Removing b and replacing each *b access with a produces the warning. Expected result Cppcheck should report the missing free in both forms. Verification...
Hi, I found a false negative regarding the rule invalidContainer. Cppcheck misses the use of an invalidated iterator when the vector is accessed through a reference alias. #include <vector> void f() { std::vector<int> items{1, 2, 3}; std::vector<int> &values = items; auto iter = values.begin(); values.erase(iter); ++iter; } Actual result Cppcheck does not report invalidContainer. Removing the reference declaration and replacing values with items produces the warning. Expected result Cppcheck should...
Hi, I found a false negative regarding the rule invalidContainer. Cppcheck misses the use of an invalidated vector iterator when the increment is written as an explicit operator call. #include <vector> void f() { std::vector<int> items{1, 2, 3}; std::vector<int>::iterator iter; for (iter = items.begin(); iter != items.end(); iter.operator++()) { if (*iter == 2) items.erase(iter); } } Actual result Cppcheck does not report invalidContainer. Replacing iter.operator++() with ++iter produces the warning....
Hi, I found a false negative regarding the rule autoVariables. Cppcheck misses an escaping local address when it passes through a pointer temporary. void f(int **out) { int local = 1; int *temporary = &local; *out = temporary; } Actual result Cppcheck does not report autoVariables. Replacing the last two statements with *out = &local; produces the warning. Expected result Cppcheck should report that the address of the local variable is assigned through the output parameter in both forms. Verification...
Hi, I found a false negative regarding the rule arrayIndexOutOfBounds. Cppcheck misses an out-of-bounds write when array indexing is written as pointer arithmetic. int a[2]; void f() { *(a + 2) = 0; } Actual result Cppcheck does not report arrayIndexOutOfBounds. Replacing *(a + 2) = 0 with a[2] = 0 produces the warning. Expected result Cppcheck should report the out-of-bounds write in both forms. Verification The issue was reproduced with: cppcheck --output-format=xmlv2 --enable=all array_pointer.cpp...
Hi, I found a false negative regarding the rule AssignmentAddressToInteger. Cppcheck misses the pointer-to-integer conversion when it is written as a compound assignment. int f(int *p) { int a = 0; a += p; return a + 4; } Actual result Cppcheck does not report AssignmentAddressToInteger. Replacing a += p with a = a + p produces the warning. Expected result Cppcheck should also report the pointer-to-integer conversion in the compound assignment. Verification The issue was reproduced with: cppcheck...
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15070
The syntaxError comes from Tokenizer::findGarbageCode. (line numbers from eb4b6526b3502ee779a74019f814d45d890427ba) Breakpoint 1.1, Tokenizer::syntaxError (this=0x7fffffffc550, tok=0x555556240920, code="") at /home/tsteven4/work/cppcheck/lib/tokenize.cpp:8441 8441 { (gdb) bt #0 Tokenizer::syntaxError (this=0x7fffffffc550, tok=0x555556240920, code="") at /home/tsteven4/work/cppcheck/lib/tokenize.cpp:8441 #1 0x00005555556f183f in Tokenizer::findGarbageCode (this=0x7fffffffc550) at /home/tsteven4/work/cppcheck/lib/tokenize.cpp:9113...
cppcheck reports a false positive syntaxError on c++20 bitfields that contain both a size and a brace initializer, which were allowed in c++20. A test case below includes sizes from more complex integral constant expressions, but handling the simple case "int m5:5{55};" would allow the most common usage to proceed in cppcheck. I reproduced this with 2.19.0 on ubuntu 26.04, but it also fails with main@eb4b6526b3502ee779a74019f814d45d890427ba cppcheck --enable=all --std=c++20 test.cc Checking test.cc...
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15061
Added here: https://trac.cppcheck.net/ticket/11563
The false negative with visible function definition looks similar to https://trac.cppcheck.net/ticket/14804
Added here: https://trac.cppcheck.net/ticket/15058
I don't get a syntaxError with latest head.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15059
Hi, I found a false negative in Cppcheck 2.21.0 when a boolean comparison result is multiplied into the divisor. Affected tool Cppcheck 2.21.0 Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer int divide_by_boolean_product(int x, int y) { int divisor = (x < 0) * y; return 1 / divisor; } Reproduction command cppcheck --version cppcheck --enable=warning --std=c11 --checkers-report=checkers.txt --template='{file}:{line}:{column}: [{id}] {message}' cppcheck-zerodiv-fn-boolean-product.c...
template <typename T> concept TQueue = requires(const T & t) { { t.empty() } -> std::same_as<bool>; }; it seems all ok was till version 2.20.0
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15058
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15057
Ticket is marked as fixed, but initial case is not fixed in cppcheck 2.22.0.
cppcheck 2.22.0 generates unusedPrivateFunction and unusedFunction for the following code: #define CASE(msg, handler) \ case msg: CASE_##msg((handler)) #define MSG1 1 #define CASE_MSG1(handler) handler() class Object { private: int m_num; public: Object() : m_num(0) {} static void msg_proc(int msg, void *context) { switch (msg) { CASE(MSG1, reinterpret_cast<Object*>(context)->msg1_handler); } } private: void msg1_handler() { m_num = 1; } }; int main() { Object obj; Object::msg_proc(MSG1, reinterpret_cast<void*>(&obj));...
cppcheck 2.22.0 generates functionStatic for the following code: #define CASE(index, method) \ case index: return CASE_##method((method)) #define CASE_method1(method) method() class Object { private: int m_num; public: Object() : m_num(0) {} void call(int index) { switch (index) { CASE(1, method1); } } private: void method1() { m_num = 1; } }; int main() { Object().call(1); return 0; } test\main.cpp:11:7: style: The member function 'Object::call' can be static. [functionStatic] void call(int index)...
cppcheck 2.22.0 generates noDestructor for the following code: #include <windows.h> class NonCopyable { protected: NonCopyable() {} private: NonCopyable(const NonCopyable&); NonCopyable& operator=(const NonCopyable&); }; class Brush : public NonCopyable { private: HBRUSH m_brush; public: explicit Brush(HBRUSH brush) : m_brush(brush) {} ~Brush() { if (m_brush) DeleteObject(m_brush); } }; class GDI : public NonCopyable { private: Brush m_brush; public: GDI() : m_brush(CreateSolidBrush(RGB(0, 0, 0)))...
Cppcheck 2.22.0
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15052
Example added here: https://trac.cppcheck.net/ticket/14239
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15051
See https://trac.cppcheck.net/ticket/10
See https://trac.cppcheck.net/ticket/14239
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when destruction of a temporary object changes a global value to zero before a division. Affected tool Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer int global; struct Value { Value() { global = 1; } ~Value() { global = 0; } }; int test() { Value{}; return 1 / global; } Reproduction command cppcheck --version cppcheck --enable=warning...
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when a constant argument makes a division inside a function-template instantiation divide by zero. Affected tool Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer bool unknown(); template <class T> void divide(T value) { if (unknown()) value = 1 / (value - 5); } void test() { divide<int>(5); } Reproduction command cppcheck --version...
Hi, I found a false negative in Cppcheck 2.21.0 when a switch case constrains the divisor to zero. Affected tool Cppcheck 2.21.0 Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer int divide_in_zero_case(int value) { switch (value) { case 0: return 1 / value; default: return 0; } } Reproduction command cppcheck --version cppcheck --enable=warning --std=c11 --checkers-report=checkers.txt --template='{file}:{line}:{column}: [{id}] {message}' cppcheck-zerodiv-fn-switch-case.c...
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when a helper writes zero through a pointer before the pointed-to value is used as a divisor. Affected tool Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer void set_zero(int *value) { *value = 0; } int test() { int value; set_zero(&value); return 1 / value; } Reproduction command cppcheck --version cppcheck --enable=warning --std=c++17...
Hi, I found a false negative in Cppcheck 2.21.0 when two branch constraints establish that an expression used as a divisor is zero. Affected tool Cppcheck 2.21.0 Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer int divide_after_two_constraints(int x, int y) { if (y != 0) return 0; if (x + y != 0) return 0; return y / (x + y); } Reproduction command cppcheck --version cppcheck --enable=warning --std=c++11 --checkers-report=checkers.txt --template='{file}:{line}:{column}:...
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when memset zeroes a local integer before it is used as a divisor. Affected tool Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer #include <cstring> int test() { int value = 1; std::memset(&value, 0, sizeof(value)); return 1 / value; } Reproduction command cppcheck --version cppcheck --enable=warning --std=c++17 --checkers-report=checkers.txt...
Hi, I found a false negative in Cppcheck 2.21.0 when a logical expression selects a zero-valued ternary branch. Affected tool Cppcheck 2.21.0 Affected checker Cppcheck CheckOther::checkZeroDivision (zerodiv / zerodivcond) Minimal reproducer int divide_after_logical_ternary(bool left, bool right) { int divisor = (left || right) ? 0 : 1; return 1 / divisor; } Reproduction command cppcheck --version cppcheck --enable=warning --std=c++11 --checkers-report=checkers.txt --template='{file}:{line}:{column}:...
We don't warn about the expression return true || divisor;, which is arguably dubious, but may be intentional, similar to if (false) etc. So we won't report the induced unreadVariable either.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15037
There is a deliberate bailout to allow "trivial" initialization.
See https://trac.cppcheck.net/ticket/14405
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15036
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15035
Hi, I found a false negative in Cppcheck 2.21.0 when a local variable is used only on the unevaluated right-hand side of a short-circuit expression. Affected tool Cppcheck 2.21.0 Affected checker unreadVariable Minimal reproducer int test() { int source = 0; int divisor = source; return true || divisor; } Reproduction command cppcheck --version cppcheck --enable=all --inconclusive --check-level=exhaustive --std=c++17 --output-format=xmlv2 mutant-cppcheck-unreadvariable-fn-short-circuit-rhs.cpp Current...
Cppcheck 2.21.0 misses a scalar store that is never read before a switch completes. The minimal trigger contains no loop or continue. Affected tool and checker Cppcheck 2.21.0, unreadVariable / CheckUnusedVar liveness handling. Minimal reproducer void test(int input) { int value; value = 0; switch (input) { case 0: break; default: break; } } Reproduction command cppcheck --enable=all --inconclusive --check-level=exhaustive --std=c++17 \ --template='{file}:{line}:{column}: [{id}] {message}' \ mutant-cppcheck-unreadvariable-fn-switch-dead-store.cpp...
Cppcheck 2.21.0 misses an initialization whose explicit floating conversion is overwritten before the initialized value is read. Affected tool and checker Cppcheck 2.21.0, redundantInitialization. Minimal reproducer void initialize(double &); float test() { double input; initialize(input); float value = (float)input; value = 3.14f; return value; } Reproduction command cppcheck --enable=all --inconclusive --check-level=exhaustive --std=c++17 \ --template='{file}:{line}:{column}: [{id}] {message}'...
Cppcheck 2.21.0 does not report a dead first store when its value is zero, although the otherwise equivalent nonzero store is reported as redundantAssignment. Affected tool and checker Cppcheck 2.21.0, redundantAssignment. Minimal reproducer void test() { int value; value = 0; value = 1; (void)value; } Reproduction command cppcheck --enable=all --inconclusive --check-level=exhaustive --std=c++17 \ --template='{file}:{line}:{column}: [{id}] {message}' \ mutant-cppcheck-redundantassignment-fn-zero-overwrite.cpp...
Hi, I found a false negative in Cppcheck 2.21.0 when a pointer allocated by scalar new is stored in an object member and released with delete[]. Affected tool Cppcheck 2.21.0 Affected checker mismatchAllocDealloc Minimal reproducer struct Owner { int *data; }; void test() { Owner owner; owner.data = new int; delete[] owner.data; } Reproduction command cppcheck --version cppcheck --enable=warning --inconclusive --check-level=exhaustive --std=c++17 --checkers-report=checkers.txt --template='{file}:{line}:{column}:...
Hi, I found a false negative in Cppcheck 2.21.0 when an indexed member access occurs between a scalar allocation and mismatched array deletion. Affected tool Cppcheck 2.21.0 Affected checker mismatchAllocDealloc Minimal reproducer struct Item { int value; }; void test() { Item *item = new Item; item[0].value = 0; delete[] item; } Reproduction command cppcheck --version cppcheck --enable=warning --inconclusive --check-level=exhaustive --std=c++17 --checkers-report=checkers.txt --template='{file}:{line}:{column}:...
it is because in cfg/posix.cfg the return value is calculated as <returnValue type="int">arg1==0 &0</returnValue> Is it as simple as that ? That stanza is for <function name="ffsl,ffsll"> but not ffs itself.
Thanks for reporting, example added here: https://trac.cppcheck.net/ticket/11222