Using 2.5 (going at least back to 1.85), I observed this false-negative:
$ cat x.c
typedef enum { FOO, BAR, BAZ } myenum;
typedef int myint;
int main(void){
enum { A, B, C } en;
myenum e;
myint i;
int n;for(;;){en= A;
call(en);e= BAZ;
call(e);i=42;
call(i);n=42;
call(n);}}
cppcheck --enable=all x.c
Checking x.c ...
x.c:7:11: style: The scope of the variable 'i' can be reduced. [variableScope]
myint i;
^
x.c:8:9: style: The scope of the variable 'n' can be reduced. [variableScope]
int n;
^
I would expect the same message for variables 'en' and 'e' as well.
Does anyone else consider this a bug?
Regards,
Jens
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello, world\n
Using 2.5 (going at least back to 1.85), I observed this false-negative:
cppcheck --enable=all x.c
Checking x.c ...
x.c:7:11: style: The scope of the variable 'i' can be reduced. [variableScope]
myint i;
^
x.c:8:9: style: The scope of the variable 'n' can be reduced. [variableScope]
int n;
^
I would expect the same message for variables 'en' and 'e' as well.
Does anyone else consider this a bug?
Regards,
Jens
Thanks! I agree. I created a ticket: https://trac.cppcheck.net/ticket/10365