[cfe-dev] Static analyzer: add smart pointer checker
Ted Kremenek
kremenek at apple.com
Fri Jan 6 12:58:20 PST 2012
Seems fairly straightforward and wouldn't require much analysis. If this is specific to 'std', we could consider making this a compiler warning. I'm fine with trying this out as a static analyzer check first.
On Jan 6, 2012, at 7:40 AM, Dmitri Gribenko wrote:
> Hello,
>
> 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
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list