Thank you for the report.
Please use the code formatting syntax like this:
~~~
code goes here
~~~
Otherwise the code will be shown wrong.
I've extracted this from the attachment:
// Test Case:// When: cppcheck --enable=warning warning.cpp// Expect: Zero warnings// Actual: (warning) Member variable 'Test::_warning_map' is not initialized// in the constructor.// Synopsis: Warning is generated for templated types with more than one// identifier. No warning is generated for '_warning_vector' which// only has one identifier.#include<map>#include<string>#include<vector>classTest{public:Test(){}protected:std::string*_warning=nullptr;std::vector<std::string>*_warning_vector=nullptr;std::map<int,int>*_warning_map=nullptr;};intmain(intargc,char*argv[]){Test();return0;}
I can reproduce the warning with the latest development version.
I am not absoulutely sure if this ticket already reports the same or just a very similar/related problem: https://trac.cppcheck.net/ticket/8146
Another related ticket that is missing the case reported here is https://trac.cppcheck.net/ticket/5499.
It seems like the direct member initialization inside a class definition that is new in C++11 is not yet handled correctly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
amai detected something similar and wrote about it in a ticket comment.
It seems that there is a problem as soon as more than one template parameter is used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
// Test Case:
// When: cppcheck --enable=warning warning.cpp
// Expect: Zero warnings
// Actual: (warning) Member variable 'Test::_warning_map' is not initialized
// in the constructor.
// Synopsis: Warning is generated for templated types with more than one
// identifier. No warning is generated for '_warning_vector' which
// only has one identifier.
include
include <string>
include <vector>
class Test {
public:
Test() {}
protected:
std::string* _warning = nullptr;
std::vector<std::string>* _warning_vector = nullptr;
std::map<int, int="">* _warning_map = nullptr;
};
int main(int argc, char* argv[]) {
Test();
return 0;
}
Thank you for the report.
Please use the code formatting syntax like this:
Otherwise the code will be shown wrong.
I've extracted this from the attachment:
I can reproduce the warning with the latest development version.
I am not absoulutely sure if this ticket already reports the same or just a very similar/related problem:
https://trac.cppcheck.net/ticket/8146
Another related ticket that is missing the case reported here is https://trac.cppcheck.net/ticket/5499.
It seems like the direct member initialization inside a class definition that is new in C++11 is not yet handled correctly.
std::map somehow seems to be special here, so i created ticket 8498
In my tests I discovered std::pair<int, int=""> also yields a warning. As does MyClass<int, int="">. However, MyClass<int> does not.
Thank you for looking into this.
amai detected something similar and wrote about it in a ticket comment.
It seems that there is a problem as soon as more than one template parameter is used.