Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28179 Discussions

Intel Fortran what happens with runtime error checking turned off?



I was wondering what exactly happens when runtime error checking in Intel Fortran is turned off (especially for array bounds checking) and such error actually does occur?

This afternoon I encountered such a runtime error for array bounds (generating a severe segfault error). The decision was made to turn off this check and recompile the program. It runs then smoothly (that is, seems to...) but what then is going on when array bounds are overwritten?

The code was like this:

Do While (A(i+1) < B) 
A(i+1) = A(i)
i = i+1
End Do

At certain point i +1 becomes larger than the size of A. Since the program runs on without halting it appears to somehow terminate the loop. Is the loop exited then on boundary violation or does it terminate in any other way?

Searched the internet for any answer but could not find any.

What is the consensus for turning on runtime error checking? In production code it can have serious consequences so I opt for turning it off  for production code and only use it for debug versions. Any other opinions?

0 Kudos
3 Replies
Black Belt

Anything can happen. The behavior of a program with errors is "unpredictable". That includes (i) producing incorrect results, (ii) producing almost correct results, (iii) producing correct results, (iv) access violation, program abort with or without traceback, etc.

Because of the large number of combinations of multiple errors, you cannot expect an answer to "what exactly happens". My answers above only cover "what may happen".

Black Belt Retired Employee

If you turn off runtime error checking, and an invalid condition occurs (such as array access out of bounds), the results are unpredictable. Sometimes you'll get an error such as an access violation/segfault, sometimes you'll get the wrong result for any of uncountable reasons, and sometimes nothing untoward will happen. It all depends on the type of error and what it does to the program state.

In the case you show above, the memory location just past the allocated storage for the array will get overwritten. What happens after that depends on how that memory location is used - if it is used at all.

It is common to disable runtime checks for production code, assuming it has been fully tested.


Thanks Steve, mecej4,


that's what I expected to happen. Not sure if the compiler would insert any code though for these type of things to be caught and do something sensible.

Maybe I should check the stack to see what is going on and especially why it manages to end the loop anyhow.

0 Kudos