Memory error not deteched

Memory error not deteched

Hi,

I am attaching a simple fortran code

       implicit none
       integer*8 i
       real*8 a(50)
       do i=1,100
       a(i)=i
       enddo
       write(*,*)'no error in the program'
       stop
       end

and I am using composerxe-2011.4.191 compiler.  If i compile with gfortran i get the error

Segmentation fault

but the ifort does not give me error.

What I should do to memrory overflow error ?

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

In case you compile with optimization ( which is the default), the Intel Fortran Compiler will detect, that you are not using the array a() and will remove your loop completely. Have a look at the assembler code ( option -S on Linux) and you will see, that there is no loop generated. Thus the errror cannot be detected - simply because the error doesn't make it into the code generated.

The Intel compiler offers the option "-check bounds" to reliable detect such errors. Give it a try. You will get a corresponding error message and a stack trace. See user manual for more details

You should not rely on such errors being detected by simply running the code. A segmentation violation error only occurs, in case the memory beyond your array is not allocated at all. Frequently this area however belongs to other objects of your code and thus you corrupt data but you not necessarily get a segmentation fault. The bug might show up much later then and it might be difficult to link this to the initial cause.

For more complex to detect memory errors, the Intel Inspector XE offers static source code analysis ( in combination with the compiler) and dynamic memory analysis. See http://software.intel.com/en-us/intel-inspector-xe/ for more.

thanks for you suggestions.
ifort -check bounds filename.f
is showing memory error.

Leave a Comment

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