[ODE] Compiling as Release differs from Debug

Martin C. Martin martin at metahuman.org
Thu Dec 4 08:59:55 MST 2003


Steve Baker wrote:

> For some *insane* reason, the developers of MSVC decided that in debug 
> mode,
> all variables would be pre-initialised to zero if no otherwise initialised
> by the program.  But in released code, this is not the case.

Funny, when I use MSVC, all pointers are initialized to invalid values. 
  This means that, e.g., if a given memory location was a valid pointer, 
then gets reused under a different name, I'll get an error if I 
dereference it.  This isn't true in release builds.

So I just did a test.  Here's the (very short) program:

#include <stdio.h>

void main()
{
	void *p;
	int i;
	float f;

	printf("p: 0x%x, i: %d, f: %f\n", p, i, f);
}

Compiling with MSVC v 6.0 gives warnings that variables are 
uninitialized.  The debug build produces:

p: 0xcccccccc, i: -858993460, f: -107374176.000000

And the release:

p: 0x4090f8, i: 4231416, f: 0.000000

The debug integer is actually hex "all c's" as well.  Globals are 
initialized to zero in both builds.

> So, uninitialised variable bugs are hard to find in debug mode - but 
> show up
> quite well in release mode.  Hence, the debug mode does a really good 
> job of
> hiding the very bugs you'd hope it would help you find.  What *were* they
> thinking when they did that?

Just because Microsoft uses FUD doesn't mean you should.  There are lots 
of things to hate about MSVC, we don't need to make up new ones.

- Martin



#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################

#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################


More information about the ODE mailing list