- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Mike
You say you "know" that the function should've returned -1. Have you verified that by using the debugger?
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
TimH
TimH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very high probability of an uninitialized variables being the culprit. Maybe someone will eventually see the light.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Mike
Mike

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page