Run-Time Check Failure #3

  • Thread starter Chris Stankevitz
  • Start date
C

Chris Stankevitz

Hi,

MSVC 7.1 .net 2003, native c++. I received this runtime message today for
the first time in my life (and I've used MSVC for a long time):

Run-Time Check Failure #3 - The variable 'doCancel' is being used without
being defined.

The word "defined" should say "initialized". The code that triggered it
looked a little like this:
bool doCancel; // uninitialized
if(doCancel) // use of uninitialized
...

My question:

I've used hundreds of uninitialized variables in the past few years. Most
of them I found only while searching for strange runtime behavior. How come
MSVC never popped up this very helpful warning before?

I run debug all the time, so the answer is not "because I've always run in
release mode."

Thanks,

Chris
 
W

William DePalo [MVP VC++]

Chris Stankevitz said:
I've used hundreds of uninitialized variables in the past few years. Most
of them I found only while searching for strange runtime behavior. How
come MSVC never popped up this very helpful warning before?

I run debug all the time, so the answer is not "because I've always run in
release mode."

One of the primary techniques that malware/spyware/virus writers use to
inflict pain is to mess up the stack.

At about the time that viruses started making the evening news, the compiler
was modified to detect the buffer overruns and whatnot that play havoc with
the stack. I might be wrong, but I think that the uninitialized automatic
variable checks were added at the same time.

Just by the way, and on a slightly tangential note, Brandon Bray of the VC++
compiler team has an article about some of the newer checks performed by the
compiler here:

http://www.codeproject.com/tips/seccheck.asp

Regards,
Will
 
C

Chris Stankevitz

William DePalo said:
Just by the way, and on a slightly tangential note, Brandon Bray of the
VC++ compiler team has an article about some of the newer checks performed
by the compiler here:


Will,

Thanks for the help. I just enabled the run time checks on all the "vcproj"
in my "sln" for debug.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top