Re: Upgrading to VS2008 Standard worth my time?
In article <eoEkIxatIHA.4076@TK2MSFTNGP06.phx.gbl>,
Alex Blekhman <tkfx.REMOVE@yahoo.com> wrote:
[...] VS2008 can finally detect uninitialized value access, I
might actually upgrade.
VS could detect uninitialized variables for ages already. You need
to compile with warning level 4, then you'll see C4701 warnings.
It can detect only the most trivially uninitialized variables.
I've posted this example before, which generates *zero* warnings
(compile or runtime) with VS2005 SP1 at warning level 4, debug
build. Here's the entire source code, and it has a 50/50 chance of
using a variable uninitialized. [Complete source & .vcproj/.sln
files could be uploaded, it's not much at all.]
--- Begin main.cpp
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void foo(int& v)
{
if(rand() & 0x01)
v = 0;
}
int main(int /*argc*/, char** /*argv*/)
{
srand((unsigned int)time(NULL));
int v;
foo(v);
printf("v = %d", v);
return 0;
}
--- end main.cpp
Static code analysis like Coverity can detect this now. Dynamic
runtime checks like Boundschecker or Valgrind (linux only) can detect
this as well. I'd like to hope that VS2008 does better at this test,
but I have little faith in MS.
Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein