- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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 ?
링크가 복사됨
2 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.