Different result between release and debug

Different result between release and debug

We have a fairly big C/Fortran program and we use the 6.6A version of CVF. I have a problem with a call in a if statement. If the function returns < 0 I should go into the if statement but I don't in the release version even if I know that the function should have returned -1. If I first put the result in a local variable, the if statement works. Any ideas what the problem can be?

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

These kinds of errors often result from the use of uninitialized variables. Try turning off the optimizations for the release configuration to see if the results change.

You say you "know" that the function should've returned -1. Have you verified that by using the debugger?


I have made some printouts and they give -1. I have searched for uninitialized variables and haven't found any. The 2 functions I use are quite small so it shouldn't be hard to find uninitialized variables.

Try building a debug configuration of your application. Set breakpoints at the start of your Fortran function and at the point where it returns a value to the calling routine. Start the application and step through the function to verify that it's returning -1 and that the calling routine is receiving -1. Continue stepping through the calling routine after the function returns to see if the logic sends it through the proper branch of your IF statement.


One other possibility (though it appears in our case slim). You should never do critical branches on floating pt variables. Because of complicated precision handling rules, things can be VERY different depending on some entirely irrelevant operations such as writing to disk, etc. These rules can be controlled by compiler switches but they are by default VERY different between debug and release setting.


Very high probability of an uninitialized variables being the culprit. Maybe someone will eventually see the light.

Leave a Comment

Please sign in to add a comment. Not a member? Join today