- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for you suggestions.
ifort -check bounds filename.f
is showing memory error.
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