Differences that may occur between Debug and Release builds?

c++

Solution

Here's a summary of a few differences: http://msdn.microsoft.com/en-us/library/aa236698%28v=vs.60%29.aspx. It includes:

- heap layout (the use of a debugging memory allocator)

- macros (including assert statements, as well as anything included in "#ifndef NDEBUG", which can be substantial differences in some cases -- e.g., I know that some boost libraries add extra fields to structs when compiled in debug mode, which can be used to perform sanity checks)

- optimizations (mostly disabled in debug builds)

- initialization & bad pointers: uninitialized variables have undefined state until you assign to them; but in debug builds, they'll often be initialized to some known state (eg all zero or all #CCCCCCC etc).

Problem

I was asked today in an interview to list four differences that may occur between debug and release builds. I suppose they meant differences in behavior and not differences such as debug information and whatnot. I was only able to name two: - Debug builds are generally much slower due to some functions not being inlined. - Due to the difference in speed, in multi-threaded programs that have race conditions, these race conditions may become apparent in only one of the two builds. What other differences could I have named?

Original source

Related problems