Dear Cppcheck team,
The following code was pointed out as an error using another checker tool, as the class member is shadowed in the member function.
This may be of interest as a --inconclusive error, perhaps excluding const members or member functions:
==== class A { private: int a; public: A() { a=0;} void set(int); };
void A::set(int a) { a=1; } ====
Neither gcc nor Cppcheck 1.74 does not flag this error, as far as I can see.
$ cppcheck --version Cppcheck 1.74 $ g++ --version | head -n 1 g++ (Debian 5.4.0-6) 5.4.0 20160609 $ g++ test.cpp -Wall -o test -c $cppcheck --inconclusive test.cpp Checking test.cpp...
Thanks.
The shadowing compiler warning can be enabled with "-Wshadow"
Thanks!
There is this ticket about detecting shadow variables: http://trac.cppcheck.net/ticket/1384
Log in to post a comment.
Dear Cppcheck team,
The following code was pointed out as an error using another checker
tool, as the class member is shadowed in the member function.
This may be of interest as a --inconclusive error, perhaps excluding
const members or member functions:
====
class A
{
private:
int a;
public:
A() { a=0;}
void set(int);
};
void A::set(int a)
{
a=1;
}
====
Neither gcc nor Cppcheck 1.74 does not flag this error, as far as I can see.
$ cppcheck --version
Cppcheck 1.74
$ g++ --version | head -n 1
g++ (Debian 5.4.0-6) 5.4.0 20160609
$ g++ test.cpp -Wall -o test -c
$cppcheck --inconclusive test.cpp
Checking test.cpp...
Thanks.
The shadowing compiler warning can be enabled with "-Wshadow"
Thanks!
There is this ticket about detecting shadow variables:
http://trac.cppcheck.net/ticket/1384