Static code anlysis


  • I am looking for a summary of static code analysis features in VS 2005. In other words, what are to features and more importantly what are its shortcomings!

    In the meantime, I have two questions about it. I wrote this simple piece of code:

    int _tmain(int argc, _TCHAR* argv[])
        char* tab=new char[10];
        char* tab2=new char[10];
        char* tab3=new char[10];
        char* tab4=new char[10];

        return 0;

    Whenever I run code analysis on it I get only 3/4 memory leaks detected. In fact this number is always short of one, which means that nothing is detected if only one memory leak exists. Why is that?

    Also, a theoretical question: It should be obvious to anyone that static code analysis is an undecidable problem when detecting memory leaks. The only feasible way of detecting memory leaks is by running the program and seeing what remains undeleted after its been shut down. How is this solved in VS code analysis? Does it always show a warning about a memory leak, even if it is not 100% sure that it will occur? Or does it not detect all possible memory leaks?
    Thursday, March 15, 2007 11:45 PM