1

I'm trying to use Code Analysis in VS2010, but it's not working.

My sample appl:

#include "stdafx.h"
#include <malloc.h>

int getj() {
        return 10;
}

int a(int *n) {
        int b = *n;
        int c = 1/b;
        return c;
}

int _tmain(int argc, _TCHAR* argv[]) {
        int *a;

        a = (int *)malloc(10*sizeof(int));
        if( a ) {
                free( a );
                a[0] = 12;
                a[getj()] = 12;
        }

        return 0;
}

To start analysis, I using "Analyze-> Run Code Analysis on ...."

and logs :

1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
1>Build started 2013-07-01 17:45:40.
1>_PrepareForClean:
1>  Deleting file "Debug\test1.lastbuildstate".
1>InitializeBuildStatus:
1>  Creating "Debug\test1.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  stdafx.cpp
1>  test1.cpp
1>Manifest:
1>  Deleting file "Debug\test1.exe.embed.manifest".
1>LinkEmbedManifest:
1>  test1.vcxproj -> D:\test1\Debug\test1.exe
1>RunCodeAnalysis:
1>  Running Code Analysis...
1>  **Code Analysis Complete -- 0 error(s), 0 warning(s)**
1>FinalizeBuildStatus:
1>  Deleting file "Debug\test1.unsuccessfulbuild".
1>  Touching "Debug\test1.lastbuildstate".
1>![enter image description here][1]
1>Build succeeded.
1>
1>Time Elapsed 00:00:03.40
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Config:

On the "Property page", I have turned on:

-Enabled Code Analysis ob Build (defines....

-Enabled Code Analysis for C/C++ on Build

-Supress results from ...

-and Ruls Set ->AllRules

My question is what I'm doing wrong, or how to run code analysis in VS2010 ?

thanks

  • Paste the command line this generates (from the properties window c++ -> command line) – Mike Vine Jul 01 '13 at 18:28
  • /ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\test1.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze /errorReport:queue – user2539653 Jul 01 '13 at 18:51

0 Answers0