Return to Home
  View the contents of your Cart View cart  
  0 item(s) in cart  
  Checkout  

Gimpel Software - Discussion Forum
Discussion Forum
We invite you to use this forum to communicate with other PC-lint and FlexeLint users. You do not need to log in to post a message. WARNING: Your email address will not be encrypted. We recommend that you obfuscate it as protection from web crawlers. To receive technical support directly from Gimpel Software, please follow the guidelines at http://www.gimpel.com/html/support.htm
Reply Form
Original Message:
Hi.

For the following exmaple PC-Lint 8.0o issues 
Warning 429: "Custodial pointer 'child' has not 
been freed or returned". However, it is freed by 
the 'pa' object as it contains pointer 
to 'child' and calls delete for it in the 
destructor. I understand, that it is not trivial 
for PC-Lint to find this out, so I have 
specified semantic for constructor. But this 
semantic specification does not work. What is 
wrong?


//lint -sem(Obj::Obj,custodial(t))
class Obj {
public:
  Obj() : m_child( static_cast<Obj*>( 0)) {}
  Obj(Obj* parent)
    : m_child( static_cast<Obj*>( 0))
  {
    parent->setChild(this);
  }
  ~Obj()
  {
    try { delete m_child; } catch(...) { }
  }

  void Print() const throw() { }

private:
  void setChild( Obj* o) { m_child = o; }
  Obj* m_child;
};


void main(void)
{
  Obj pa;
  Obj *child = new Obj( &pa);

  pa.Print();
  child->Print();
}
Subject:
Name:
Email:
Message:
Please type the four digit number on the right: