Quantcast
Channel:
Viewing all articles
Browse latest Browse all 44011

Forum Post: False positive dangling pointer error?

$
0
0
Hello Can anyone explain me, why DevPartner thinks that there's a problem with dangling pointer? I can't see any problems here, is it false positive report? Any reasons? We are using DevPartner 10.5.2 (i think) and Visual Studio 2010 on 64-bit Windows 7 //------------------ struct CClassA { public:     CClassA()    {};     ~CClassA()    {}; }; //------------------ class CClassB { public:     CClassB()    {};     ~CClassB()    {};     void init()     {         m_pA = new CClassA();     }     void deinit()     {         delete m_pA;        // somehow destruction of this object will lead to this issue         m_pA = NULL;     } protected:     CClassA *  m_pA; }; //------------------ class CClassC { public:     CClassC()    {};     ~CClassC()    {};     void init()     {         m_pB = new CClassB();         m_pB- init();     }     void deinit()     {         m_pB- deinit();         delete m_pB;        // error here: "Pointer m_pB, allocated by global_operator_new, has already been freed."     } protected:     CClassB *    m_pB; }; //------------------ int main(int argc, char * argv[]) {     CClassC * pC = new CClassC();     pC- init();     pC- deinit();     delete pC;     return 0; }   Thanks.

Viewing all articles
Browse latest Browse all 44011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>