Differences between Debug and Release versions?

General discussion about C/C++

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Differences between Debug and Release versions?

Postby Mvtrotz » Fri Jul 10, 2009 2:07 pm

Hello:
I am trying to write a C++ program on a Windows XP computer using Visual C++ 6.0. I have noticed, however, that the program produces one set of results when the "Debug" build is run (i.e. the .exe file created when the Win32-Debug build configuration is selected as the active one), and a different set of results if the program is built in Release mode and then run. I was wondering if there was any plausible reason for this, as I would have expected that the only difference between the two builds would be the use of additional functionality of some sort under the Debug version to enable breakpoints, etc.

Thanks in advance.


Michael
Mvtrotz
 
Posts: 6
Joined: Thu Jul 09, 2009 8:50 pm

Re: Differences between Debug and Release versions?

Postby MXP » Fri Jul 10, 2009 3:00 pm

Debug versions generate information within the binary to help with debugging. Debug version will also generally disable any optimizations done by the compiler so that when you are debugging your program you can step through it line by line as written rather than in the crazy way the compiler has decided to rewrite it for the sake of performance. Release versions do not have the extra data and they do have the optimization and so they are faster and smaller.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: Differences between Debug and Release versions?

Postby Mvtrotz » Fri Jul 10, 2009 3:53 pm

Colin Jeanne wrote:Debug versions generate information within the binary to help with debugging. Debug version will also generally disable any optimizations done by the compiler so that when you are debugging your program you can step through it line by line as written rather than in the crazy way the compiler has decided to rewrite it for the sake of performance. Release versions do not have the extra data and they do have the optimization and so they are faster and smaller.


Thanks - I expected that the difference would be something along the lines you have described. However, I would expect the results produced by the two versions to be identical (otherwise the debug version would be useless)- but this is not what I am seeing. Could there be any legitimate reason for this?

Thanks.


Michael Trotz
Mvtrotz
 
Posts: 6
Joined: Thu Jul 09, 2009 8:50 pm

Re: Differences between Debug and Release versions?

Postby t i l e x » Sat Jul 11, 2009 8:33 am

There are many possible reasons why your application works in debug version and not in release. I have found an article on CodeProject describing the most common coding mistakes that may yield correct results in debug version and broken apps in release version. Mainly you want to double-check memory allocation / deallocation, out-of-bounds access and array sizes (i.e. you want to have x+1 characters for an x character long litteral string because it includes the null terminator). If you fail to find the source of your problem post any snippet you think might be causing trouble and we will try to help you find your mistake.
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest