{5} Accepted, Active Tickets by Owner (Full Description) (41 matches)

List tickets accepted, group by ticket owner. This report demonstrates the use of full-row display.

chrchr (2 matches)

Ticket Summary Component Milestone Type Created
Description
#14967 internalAstError with function pointer in if Other 2.22 defect 08/06/2026

libvips-8.18.4/libvips/iofuncs/threadpool.c:

void f(int (*fp)()) {
    if (fp && fp()) {}
}
test.cpp:2:12: error: Syntax Error: AST broken, binary operator is missing operand(s). [internalAstError]
    if (fp && fp()) {}
           ^

Requires --language=c.


#14977 internalError for valid typedef (operator=) Other defect 08/17/2026

rnp-0.18.1/src/librepgp/stream-ctx.h:

typedef struct S {
    S& operator=(const S&) = delete;
} S;
test.cpp:2:5: error: recursive typedef encountered [internalError]
    S& operator=(const S&) = delete;
    ^

Daniel Marjamäki (11 matches)

#12282 Internal error: fail to parse 1.0e4931L Other defect 12/20/2023

Example code:

static const long double shuge = 1.0e4931L;

Output:

wcc-0.0.2/src/wsh/openlibm/ld80/e_sinhl.c:0:0: error: Internal Error. MathLib::toDoubleNumber: conversion failed: 1.0e4931L [cppcheckError]

#12561 Do not should checkers report when analysis is disabled, i.e. when -E is used Usability enhancement 04/02/2024

Example output:

$ cppcheck --enable=information -E file.c 

nofile:0:0: information: Active checkers: 3/592 (use --checkers-report=<filename> to see details) [checkersReport]

#12470 False positive: legacyUninitvar, 2 guard variables False positive defect 02/23/2024

Example code:

#define T1 0
#define T2 1

int get_mode() { return T1; }

void foo(int flag, int k) {
  int status = 0;
  int type;
  int temp_type = 0;
  int mode;
  int m;

  if (flag) {
    if (0 == k) {
      type = T1;
      mode = get_mode();
      status = (T2 != mode ? 1 : 0);
    } else if (1 == k) {
      type = T2;
      status = 1;
    }
  }

  if (1 == status) {
      temp_type = type;
      if (T1 == temp_type) {
        m = mode;
      }
  }
}

#14749 cmdFilename: handle more bash special characters Other 2.22 defect 05/12/2026

We use popen to execute addons. Even though I believe Cppcheck should only be used in trusted/safe environments, we could be careful about the commands that is executed to not leave a door open for some kind of remote execution vulnerabilities.

We should escape or reject certain characters in the command line that the shell could treat in unwanted ways. I.e. a ";" in a filename could be treated as a command separator.

Filenames are quoted if they contain spaces but not tabs.


#10251 [meta] Support C++20 features Other enhancement 04/18/2021

See ("incomplete") reference at https://en.cppreference.com/w/cpp/20

See #7879 for C++17 features.


#11716 simplifyTypedef: function with const should be handled better Other enhancement 05/12/2023

Example code:

typedef uint16_t ftype (void);
typedef const ftype cftype;

uint16_t foo(void);

cftype* fp = foo;

We do not simplify this well. But it's not clear to me what the output should be.

According to Misra C rule 17.3 in amendment #3, the "const" is undefined behavior.


#11823 Speedup recheck Performance enhancement 07/08/2023

I will investigate if we can speedup rechecking. It should not be necessary to perform a full preprocessing of every file.


#12484 GUI: running custom addon GUI enhancement 03/02/2024

Make it possible to activate custom addons in the GUI.


#13398 Clang import: use json output instead of debug output Other enhancement 12/07/2024

Clang can nowadays output the AST in json format:

clang -cc1 -ast-dump=json file.c

Parsing the debug output is very flaky because it's sometimes inconclusive how to parse it and can fundamentally change from one clang version to another.


#13552 implement redirects for CppCheck::ExecuteCmdFn without files Other enhancement 01/13/2025

If we need to capture the output of a process we invoke we are using files to redirect the output into.

If the filenames are not unique (it happened before) that code cannot be run into parallel. It might also leave files if we exited prematurely.

So we should try to redirect the pipes in code instead of the shell.


#14850 Compilation fails on oraclelinux:8 (g++ 8.5.0 released in 2021) Other enhancement 06/16/2026

Starting docker (in cppcheck folder):

docker run --rm -v "$PWD:/root/cppcheck" -it oraclelinux:8 /bin/bash

Installing some packages:

yum install -y git python3 which epel-release
yum install -y cmake3 gcc-c++ make

Output:

# g++ -fsyntax-only -Iexternals/picojson lib/settings.cpp
lib/settings.cpp:82:1: error: function 'Settings::Settings(Settings&&)' defaulted on its redeclaration with an exception-specification that differs from the implicit exception-specification ''
 Settings::Settings(Settings&&) noexcept = default;
 ^~~~~~~~
lib/settings.cpp:83:12: error: function 'Settings& Settings::operator=(Settings&&)' defaulted on its redeclaration with an exception-specification that differs from the implicit exception-specification ''
 Settings & Settings::operator=(Settings &&) noexcept = default;
            ^~~~~~~~

gaukaugaukau (1 match)

#3734 False negative: Use of deallocated buffer passed as function argument Improve check enhancement 04/16/2012

Use of deallocated buffer (ticket #3730 split).

#include <cstring>
#include <iostream>

#define BUFFER_SIZE 10

void overrun(char * integers) {
	for (int i = 0; i != BUFFER_SIZE + 1; ++i) {
		integers[i] = i * 10;
	}
}

void corrupt_deallocated() {
	// write on freed memory
	char * integers = new char[BUFFER_SIZE];
	delete [] integers;
	overrun(integers);
}


int main() {
	corrupt_deallocated();
	return -1;
}


Tommy Bergman (1 match)

#9947 False negative: Missing virtual destructor (pointer alias) Improve check enhancement 10/09/2020

We have (had) some check for missing virtual destructors. Not sure why it does not warn below:

#include <memory>
#include <string>
#include <iostream>

class Fred {
public:
    Fred() { std::cout << "Fred\n"; }
    ~Fred() { std::cout << "~Fred\n"; }
};

class Base {
public:
    Base() { }
};

class Derived : public Base {
public:
    Derived() : Base(), x(std::make_shared<Fred>()) {}
private:
    std::shared_ptr<Fred> x;
};

int main() {
    Derived *derived = new Derived;
    Base *base = derived;
    delete base;
    return 0;
}

The message "~Fred" is not written so there seems to be a memory leak.


gsanish (1 match)

#3556 false negative: memory leak after pointer assignment Improve check enhancement 01/25/2012
struct str {
  int a;
  int b;
};

void foo()
{
  str *s = new str();
  char *v = (char *) s;
  for (int i = 0; i < sizeof(str); i++)
    v[i] = 0;
  // memory leak
}
$ cppcheck --debug MemLeak27.cpp 
Checking MemLeak27.cpp...


##file MemLeak27.cpp
1: struct str {
2: int a@1 ;
3: int b@2 ;
4: } ;
5:
6: void foo ( )
7: {
8: str * s@3 ; s@3 = new str ( ) ;
9: char * v@4 ; v@4 = s@3 ;
10: for ( int i@5 = 0 ; i@5 < 100 ; i@5 ++ ) {
11: v@4 [ i@5 ] = 0 ; }
12: }


kidkat (1 match)

#8956 Detection of compiler defines Other enhancement 01/25/2019

Currently cppcheck will just use defines provided by the command-line or the project for scans. It will not include defines that would be provided by the compiler. These could be added manually, but it would be helpful if these could be detected. In case of a project the compiler executable might already be know but it could also be specified using something like a "--compiler" command-line option.

The idea would be, that the detection is a simple source file which contains checks for the common compiler defines. This would be compiled with the specified compiler and what output the defines for cppcheck to add to the scan run.


marekzmyslowski (1 match)

#2814 Tip for new check: Infinite loops New check enhancement 05/31/2011

It is possible to detect infinite loops caused by unsigned integer overflow during loop iteration. Following loop is infinite for Limit = 255

for ( unsigned char i = 0; i < Limit; i += 2 )
{
  printf( "%i\n", i );
}

In case the variable Limit comes from unknown source, and there is no check for value 255 beforehand, cppcheck should report warning about infinite loop.


nemaakhilesh (1 match)

#7217 Enhance GUI Settings/Preferences GUI enhancement 12/17/2015
  • Add detection for geany and Qtcreator as editor application.
  • Enhance include paths/application list handling.
  • Enable auto application list population. (without the restarting application)

nilkumar (1 match)

#2778 New check: Consecutive if-statements where if-else would do New check enhancement 05/06/2011

This is a bit of a silly style issue, but I actually saw this, so I'm interested in whether it is a common issue.

if (condition)
{
}
if (!condition)
{
}

Should be:

if (condition)
{
}
else
{
}

pfultz2 (20 matches)

#9676 No function generated for call of template function Other 2.22 defect 04/16/2020
template<typename T>
void f(T t) {
        (void)t;
}

class A
{
};

static void func()
{
        A a;
        f(a);
}
##file /mnt/s/GitHub/cppcheck-fw/lib/__test.cpp
1: template < typename T >
2: void f ( T t@1 ) {
3: ( void ) t@1 ;
4: }
5:
6: class A
7: {
8: } ;
9:
10: static void func ( )
11: {
12: A a@2 ;
13: f ( a@2 ) ;
14: }



##Value flow

The template function stays intact and no f(A) function exists in the processes code. If you use a specialized template call it "works as expected" albeit with some other issues - see #9675.


#11666 FP returnDanglingLifetime with specializations and ptr to member False positive defect 04/14/2023

From the forum: https://sourceforge.net/p/cppcheck/discussion/development/thread/c52f0f2efd/

template <class T, int M, int N>
struct Matrix;

template <class T, int N>
struct Matrix<T, 1, N> {
    std::array<T, N> x;
private:
    static constexpr decltype(&Matrix::x) members[] = {&Matrix::x};
};

template <class T, int N>
struct Matrix<T, 2, N> {
    std::array<T, N> x;
    std::array<T, N> y;
private:
    static constexpr decltype(&Matrix::x) members[] = {&Matrix::x, &Matrix::y};
};

template <class T>
Matrix<T, 2, 2> O() {
    return { {}, {} };
}
Matrix.cpp:22:12: error: Returning object that will be invalid when returning. [returnDanglingLifetime]
    return { {}, {} };
           ^
Matrix.cpp:22:18: note: Passed to constructor of 'Matrix'.
    return { {}, {} };
                 ^
Matrix.cpp:22:12: note: Returning object that will be invalid when returning.
    return { {}, {} };
           ^

Tested with https://github.com/danmar/cppcheck/commit/89c33b41756be8c8a6a78b1430b2bd18d7a384f8


#13372 Template simplifier: no arguments provided to a variadic template argument Other defect 12/02/2024

Example code:

template<typename ... TParams>
class C {
public:
    void operator()(TParams... params) { x = 0; }
private:
    int x;
};

using X = C<>;

inline X x1{};

void foo(X &x2) {
    x2();
}

The debug output shows:

4: class C<> {
5: public:
6: void operator() ( TParams ... params@var3 ) { x@var4 = 0 ; }
7: private:
8: int x@var4 ;
9: } ;

At line 6 the operator should not have any arguments. It should have said :

6: void operator() ( ) { x@var4 = 0 ; }

#14938 Incorrect macro expansion in simplecpp Other 2.22 defect 07/24/2026

Running clang -E and gcc -E expands the following to nothing:

#define a(b, c) c
#define d() a
#define g(e) h(e, ) h(e, )
#define h(e, b) d()(, e)()
#define i()
g(i)

However, cppcheck incorrectly expands this to i ( ) i ( ).


#14956 FP arrayIndexOutOfBounds with break in loop False positive 2.22 defect 08/01/2026

https://sourceforge.net/p/cppcheck/discussion/general/thread/fba21a1443/:

void f() {
    int idx;
    int arr[3];
    for (idx = 0; idx < 3; idx++) {
        break;
    }
    arr[idx] = 0;
}
test.cpp:7:8: error: Array 'arr[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]
test.cpp:4:23: note: Assuming that condition 'idx<3' is not redundant
test.cpp:7:8: note: Array index out of bounds
Line 4
  = always 0
  0 always 0
  idx possible 0
  < {!<=-1,!>=2,1}
  3 always 3
Line 7
  arr always !0
  idx possible {<=2,>=3}
  = always 0
  0 always 0

#967 new check: find redundant code in if-else-statements Improve check enhancement 11/16/2009

Hi friends,

i have an idea for a new check, consider the following code

#include <iostream>
void vShowGUI(const bool &bState)
{
	std::cout << (bState?("enabled"):("disabled")) << std::endl;
	// ... manage to show gui
}

void vSetState(const bool &bState)
{
	if(bState)
	{	
		// ...
		vShowGUI(bState);
	}
	else
	{ 
		// ...
		vShowGUI(!bState);
	}
}


int main()
{
	vSetState(true);
	vSetState(false);
}

it prints the following output:

$ ./test
enabled
enabled

Here the else-body part does exactly the same as the if-body. Maybe cppcheck could warn about such issues. What do you think about this?


#1547 new check: usage of iterator pointing to deleted memory New check enhancement 03/30/2010
#include <list>
#include <iostream>
int main()
{
  std::list<int>* pl = new std::list<int>;
  std::list<int>::iterator p = pl->begin();
  delete pl;
  std::cout << *p; // <-- Usage of iterator pointing to deleted memory
}

#6358 valueFlowForward: multi variables Improve check enhancement 12/26/2014

Cppcheck fails to detect following potential null pointer dereference:

void f(bool a, bool b)
{
    int *i = a ? new int [10] : 0;
    if(b)
    {
        *i = 0;
    }
}
$ cppcheck --enable=all --debug nullptrderef3.cpp 
Checking nullptrderef3.cpp...


##file nullptrderef3.cpp
1: void f ( bool a@1 , bool b@2 )
2: {
3: int * i@3 ; i@3 = a@1 ? new int [ 10 ] : 0 ;
4: if ( b@2 )
5: {
6: * i@3 = 0 ;
7: }
8: }



##AST
 f a b , (
 int i *
 i a int 10 [ new 0 : ? =
 if b (
 i * 0 =


##Value flow
Line 3
  10:{10}
  0:{0}
Line 6
  0:{0}
[nullptrderef3.cpp:1]: (style) The function 'f' is never used.

#6527 New check: copy paste in rhs in variable assignments New check enhancement 02/20/2015

This was suggested by my colleague to detect some copy/paste. Example code:

void foo(void) {
  int x = do_something();
  int y = do_something();
}

the same rhs expression is made twice in 2 assignments. If cppcheck knows that the do_something() doesn't have any side effects we can warn about copy/pasted code.


#7562 ValueFlow: struct member, assignment Improve check enhancement 06/16/2016

not found with cppcheck 1.74:

struct bar
{
     int f;
};

int divbyzero11(struct bar* a, struct bar* b)
{
    b = a;
    a->f = 0;

    return 42 / b->f;
}

#7763 false negative: duplicateBranch for different representations of NULL Improve check enhancement 10/19/2016

No warning is shown anymore since (9cea2d6dfaed8394027e019c785fc0b9291c74ca)

bool f ()
{
     if ((*path)[0]->e->dest->loop_father
        != path->last ()->e->src->loop_father)
     {
        delete_jump_thread_path (path);
        e->aux = 0;
        ei_next (&ei);
     }
     else
     {
        delete_jump_thread_path (path);
        e->aux = NULL;
        ei_next (&ei);
     }
}

It should give

(style, inconclusive) Found duplicate branches for 'if' and 'else'.

#8133 valueFlowAfterCondition: else Improve check enhancement 07/31/2017

Coverity detected an issue in Cppcheck.

Here: https://github.com/danmar/cppcheck/blob/1.80/lib/checkstl.cpp#L1056

If the condition (!tok2 && j == i->second - 1) is false, tok2 is dereferenced.

Cppcheck should detect this issue also.

Reduced code:

void f()
{
    const Token* tok2 = tok->tokAt(2);
    unsigned int j;
    for (j = 0; tok2 && j < i->second-1; j++)
        tok2 = tok2->nextArgument();
    if (!tok2 && j == i->second-1) {}
    else
        tok2 = tok2->previous;
}

#8433 False negative: unused variable not detected when there is lambda (regression) Improve check enhancement 03/11/2018

This was reported on stack overflow: https://stackoverflow.com/questions/49221191/cppcheck-does-not-output-warnings-when-there-exists-a-line-auto-lambda/49225566

Example code:

int main(int argc, char** argv) {
    float a;
    auto lambda = [](){};
    return 0;
}

The variable a is unused but Cppcheck does not find it.


#9049 False negative: uninitialized variable with nested ifs Improve check enhancement 03/19/2019

We had a uninitialized variable in Cppcheck that we did not detect.

Revision: e98a4a6f1475db03473d544d576827e49f9a9575 File: lib/checkbufferoverrun.cpp Line: 257

Reduced example code:

void f() {

        unsigned int dimensions = 0;

        bool mightBeLarger;

        if (a) {
            dimensions = array->variable()->dimensions();
            if (dimensions >= 1 && b) {
                mightBeLarger = false;
            }
        } else {
            mightBeLarger = false;
        }

        if (dimensions == 0)
            return;

        // Positive index
        if (!mightBeLarger) { } // Error!
}

#9365 false negative: (style) Condition '...' is always true Improve check enhancement 09/23/2019

This ticket is related to #9351

#include <iostream>
int f(int x, int count)
{
    const bool isLowerThen42 = x < 42;
    if(count < (isLowerThen42 ? 2 : 3))
    {
        const bool b = isLowerThen42;
        if(isLowerThen42)
        {
                return (b?0:1); // << b is always true
        }
    }
    return 42;
}
$ g++ -c knownConditionTrueFalse.cpp && cppcheck --enable=all --inconclusive --template=cppcheck1 knownConditionTrueFalse.cpp
Checking knownConditionTrueFalse.cpp ...
[knownConditionTrueFalse.cpp:2]: (style) The function 'f' is never used.
: (information) Cppcheck cannot find all the include files (use --check-config for details)


#12433 false negative: constParameterReference (template argument deduction) Improve check enhancement 02/12/2024

Reduced from template<class ValueOrValues> static Analyzer::Result valueFlowForward() in valueflow.cpp

#include <list>
#include <string>

class C {};

static int f2(std::string, const C&);
static int f2(std::list<std::string>, const C&);

template<class T>
static int f1(T t, C& c)
{
    return f2(t, c);
}

void f()
{
    std::string s;
    std::list<std::string> l;
    C c;
    f1(s, c);
    f1(l, c);
}

Looks related to #11856.


#13377 FN knownConditionTrueFalse with early returns (regression) Improve check enhancement 12/04/2024
int f(int i) {
	bool b = true;
	if (i == 4)
		return 4;
	if (i == 7)
		return 7;
	return b ? 1 : 2;
}
Line 7
  b always {!<=-1,!>=2}
  ? possible {1,2}
  1 always 1
  : always 2
  2 always 2

b is never changed and not conditional on anything, so the value should be set.


#13630 FN: knownConditionTrueFalse (interval range in template not detected) Improve check 2.22 enhancement 02/08/2025
template <typename Char>
void f0(Char c)
{
    if (c <= 0) return;
    if (c >= 1) {;} // FN known condition always true
}

void f1(char c)
{
    if (c <= 0) return;
    if (c >= 1) {;} // TP known condition always true
}

int main()
{
    {
        char c = 'A';
        f0(c);
    }
    {
        char c = 'A';
        f1(c);
    }
    return 0;
}
$ g++ -c test.cpp && cppcheck --enable=all --debug-warnings --check-level=exhaustive --suppress=checkersReport --inconclusive --check-library  test.cpp
Checking test.cpp ...
test.cpp:11:11: style: Condition 'c>=1' is always true [knownConditionTrueFalse]
    if (c >= 1) {;} // TP known condition always true
          ^
test.cpp:10:11: note: Assuming that condition 'c<=0' is not redundant
    if (c <= 0) return;
          ^
test.cpp:11:11: note: Condition 'c>=1' is always true
    if (c >= 1) {;} // TP known condition always true
          ^

Tested with https://github.com/danmar/cppcheck/commit/f4475217021a25d4d3b86cf443f3fbe8a20fd01e


#13639 FN: knownConditionTrueFalse (std::is_void()) Improve check enhancement 02/15/2025
#include <type_traits>

void foo();

int main() {
    static_assert(std::is_void_v<void> == true);
    if(std::is_void_v<void> == true){;}
    static_assert(std::is_void_v<const void> == true);
    if(std::is_void_v<const void> == true){;}
    static_assert(std::is_void_v<volatile void> == true);
    if(std::is_void_v<volatile void> == true){;}
    static_assert(std::is_void_v<void*> == false);
    if(std::is_void_v<void*> == false){;}
    static_assert(std::is_void_v<int> == false);
    if(std::is_void_v<int> == false){;}
    static_assert(std::is_void_v<decltype(foo)> == false);
    if(std::is_void_v<decltype(foo)> == false){;}
    static_assert(std::is_void_v<std::is_void<void>> == false);
    if(std::is_void_v<std::is_void<void>> == false){;}
}
$ g++ -c test.cpp && cppcheck --enable=all --debug-warnings --check-level=exhaustive --suppress=checkersReport --inconclusive --check-library --suppress=missingIncludeSystem test.cpp
Checking test.cpp ...
test.cpp:7:39: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<void> == true){;}
                                      ^
test.cpp:9:45: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<const void> == true){;}
                                            ^
test.cpp:11:48: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<volatile void> == true){;}
                                               ^
test.cpp:13:41: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<void*> == false){;}
                                        ^
test.cpp:15:39: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<int> == false){;}
                                      ^
test.cpp:17:49: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<decltype(foo)> == false){;}
                                                ^
test.cpp:19:54: debug: valueflow.cpp:6088:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block [valueFlowBailout]
    if(std::is_void_v<std::is_void<void>> == false){;}
                                                     ^

Tested with https://github.com/danmar/cppcheck/commit/391a109d25e47b465e1d864bf1b71db80e6ba92e


#14120 TemplateSimplifier: deduction is not working Improve check enhancement 09/08/2025

Example code:

template <typename T>
void f(T b) { *b = 0; }

void bar(std::vector<int>::iterator b) {
  f(b);
}

The --debug output is:

1: template < typename T >
2: void f ( T b@var1 ) { *@exprUNIQUE b@var1 = 0 ; }
3:
4: void bar ( std :: vector < int > :: iterator b@var2 ) {
5: f (@exprUNIQUE b@var2 ) ;
6: }

remidelmas (1 match)

#3390 Filtering: show errors only for files in a certain directory (whitelist) Other enhancement 12/08/2011

Hi,

The need is rather simple: my code includes lots of external dependencies. I need to tell cppcheck where to find them, for better results, but I do not care about errors in those files.

Basically I would like to have this kind of option: cppcheck --whitelist=/path/to/project

This would automatically suppress errors on files whose path does not start with /path/to/project.

I am willing to implement it myself, I am opening this ticket to make sure this is not already done elsewhere (or already possible) and to see if you guys think this is a good idea.

Thanks and best regards, Remi


Note: See TracReports for help on using and creating reports.