Help! Wrong results in the release version!

A

arber

Hi,

I wrote a C++ program(Using VC 6.0). It's run well under debug
environment.
After i finished it and made a release version. The different results
are outputed.
Anybody have this experience? I guess that's because the optimized
compiling in the release version. How can i do?????? :-(
Really thanks for your help.

Arber
 
L

lallous

arber said:
Hi,

I wrote a C++ program(Using VC 6.0). It's run well under debug
environment.
After i finished it and made a release version. The different results
are outputed.
Anybody have this experience? I guess that's because the optimized
compiling in the release version. How can i do?????? :-(
Really thanks for your help.

Arber
Hello,

This is a compiler specific question and not much appropriate in this
newsgroup.
However, I recall there was an article named "Release vs Debug build", you
can search google for it.
 
M

Martijn Lievaart

Hi,

I wrote a C++ program(Using VC 6.0). It's run well under debug
environment.
After i finished it and made a release version. The different results
are outputed.
Anybody have this experience? I guess that's because the optimized
compiling in the release version. How can i do?????? :-(
Really thanks for your help.

As one tip, look for asserts with side effects.

HTH,
M4
 
V

Victor Bazarov

Martijn Lievaart said:
As one tip, look for asserts with side effects.

'nother tip: some compilers zero-initialise all variables in Debug
but not in Release. Initialise the necessary variables yourself.
 
G

Greg Schmidt

'nother tip: some compilers zero-initialise all variables in Debug
but not in Release. Initialise the necessary variables yourself.

Martijn and Victor's suggestions are good ones.

In my own experience, such differences have often resulted from
overrunning array boundaries. In debug mode, there are several "buffer"
bytes tacked on to the end of any memory block, which you can write to
and read from without breaking anything else (such as the variable
defined just before or just after the block in question). In release
mode, of course, these buffers vanish, and what was formerly an
innocuous bug becomes catastrophic. Debugging environments should let
you know when you have written into these buffers (although my
experience has been that they don't always), but they surely can't tell
if you are reading from them.

One other point of note. I recently worked on a project which involved
heavy amounts of floating point calculations. Running the same data
through the debug and release versions often gave results that varied by
1% or more. I stepped through the code in both situations (it's
possible, though not always good for your sanity, to enable debugging of
release builds) and saw that multiplying the same numbers did not give
the same results. Setting the "improved floating point consistency"
option (in MSVC7.1, don't know what other compilers might have such a
setting) brought them much closer together with no noticeable change in
speed.
 

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

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,315
Latest member
VernellPos

Latest Threads

Top