- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have found a problem in the 8.0 version of the compiler when bounds checking is turned on (-CB). Using the following code:
program lazyif
real(8), allocatable :: dumArray(:)
integer nSize
real(8), allocatable :: dumArray(:)
integer nSize
nSize = 0
if(nSize .gt. 0) then
allocate (dumArray(nSize))
dumArray = 1
endif
allocate (dumArray(nSize))
dumArray = 1
endif
if(nSize.gt.0 .and. dumArray(1) .ne. 0) then
write(*, '(A)') 'dumArray first element is not zero'
else
write(*, '(A)') 'lazy if succeeded'
endif
write(*, '(A)') 'dumArray first element is not zero'
else
write(*, '(A)') 'lazy if succeeded'
endif
end
If this code is compiled without -CB it works correctly and prints out 'lazy if succeeded'. If it is compiled with -CB (ifort -CB lazyif.for), a runtime error occurs
forrtl: severe (408): fort: (2): Subscript #1 of the array DUMARRAY has value 1 which is greater than the upper bound of -1
Now, on the other hand, if the code is compiled with CVF 6.6B using
df -check:bounds lazyif.for
it works correctly and prints 'lazy if succeeded'. I do not believe we had this problem with version 7.1
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are relying on an optimization choice, and not a feature. Your code is incorrect - Fortran does not have "lazy if evaluation". Fix the code by using nested IF.

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