linux - Error (Klocwork): '_M_dataplus._M_p' might be used uninitialized in this function -


'klocwork' profiller generate error ['it.second.name_._m_dataplus._m_p' might used uninitialized in function.] in following code section.

    class test {             public:                     test() { }                      test(std::string str) {                             name = str;                             cout <<"test::test object: " <<name <<endl;                     }                      ~test() {                             cout <<"test::~test object: " <<name <<endl;                     }                      string getname() {                             return name;                     }             private:                     string name;     };      class maphandler {             private:                     map<int, test> mymap;              public:                     void mapfiller();                     void mapdisplay();     };      void maphandler::mapfiller() {                            test obj1("obj1");             test obj2("obj2");             test obj3("obj3");                    mymap[1] = obj1;             mymap[2] = obj1;             mymap[3] = obj3;     }      void maphandler::mapdisplay() {                            map<int, test> tmpmap;             for(auto : mymap) {                     cout <<"object: " << it.second.getname() <<endl;                     tmpmap[it.first] = it.second;             } **//error line**     } 

but in simple compilation using [g++ -std=c++11 -wall -werror test.cpp] it's working fine.


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -