[cfe-dev] Static analyzer: add smart pointer checker

Dmitri Gribenko gribozavr at gmail.com
Fri Jan 6 07:40:14 PST 2012


I want to implement a smart pointer checker (std::shared_ptr,
std::unique) that catches specifying invalid type:

struct A
  A() { cout << "A()" << endl; }
  ~A() { cout << "~A()" << endl; }

void test()
  std::unique_ptr<A[]> p(new A[3]); // good, delete[] called
  std::unique_ptr<A> p(new A[3]); // bad, delete instead of delete[] called

Any comments?

Dmitri Gribenko

(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the cfe-dev mailing list