title: valgrind invalid read of size 4, where is the error?
body: <p>I'm new with valgrind and I'm trying to use it for memory leaks and other memory problems. In my program I have defined the following class</p>
  
  <pre><code>class LM_EXPORT LdpElement : public Visitable, virtual public RefCounted,
                               public NodeInTree&lt;LdpElement&gt;
  {
  protected:
      ELdpElement m_type;     // the element type
      std::string m_name;     // for composite: element name
      std::string m_value;    // for simple: the element value
      bool m_fSimple;         // true for simple elements
      int m_numLine;          // file line in which the element starts or 0
      long m_id;              // for composite: element ID (0..n)
      ImoObj* m_pImo;
  
      LdpElement();
  
  public:
      virtual ~LdpElement();
  
      //getters and setters
      ...
      inline ImoObj* get_imo() { return m_pImo; }
  </code></pre>
  
  <p>Valgrind is complaining in this last line "invalid read of size 4". Why? Where is the memory problem in returning the pointer?</p>