Problems debugging

Problems debugging

I need some help with debugging problems. Specifically, when I compile a release version of my code, I am getting an access violation exception (instruction references memory that cannot be read). However, when I compile the code with the default debug options, everything runs fine. How is one expected to debug a program if they cannot reproduce the problem when debugging? Has anyone else run into this problem, and, if so, what was their work around?

I have run into a similar problem with CVF before in that there is no option to initialize variables to zero. Because of this, I obtained very different results from my program depending upon whether I compiled it with debug or release options. I finally tracked down the problem to the fact that there is no option to zero out all uninitialized variables. I realize that this practice is frowned upon by the computer science elite, but without the ability to set default initialization values for variables, then a debugger is essentially useless if it gives different results depending upon how the program is compiled. I understand the reasoning behind not allowing a compiler to initialize variables - this forces the programmer to do it. But forcing a programmer to initialize all variables does not ensure that the programmer will initialize them correctly. Apparently, it just makes debugging a whole lot more difficult. Anyway, any suggestions for solving my debugging problem?

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


You can add debugging support to a "Release" configuration. Set the Release configuration as the active configuration. Select Project -> Settings -> Fortran tab -> General category. Set "Debugging level" to Full. Select the Link tab -> General category. Select "Generate debug info".

After rebuilding, you can do the same sort of debugging that you would do with a Debug build. However, some things may be a little "funny", since code can be moved/eliminated by compiler optimizations.

Good luck with finding the problem,


Leo, thanks for the information. However, I found the problem by changing the optimization option from maximum optimization to full optimization. I don't think this is a good thing for the compiler to generate instructions that try to access memory that cannot be read. I think this falls into the realm of a buggy compiler. What are your feelings on this?

If your program is correct, then optimization should always result in a correctly-running program. My guess is that you have a coding error that is revealed by optimization - this is the usual case (but not always). So, send us as short an example as you can of a program that demonstrates the problem and we'll be glad to look at it.

Retired 12/31/2016

Leave a Comment

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