- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the following invalid program
program xalloc
implicit none
integer, allocatable :: ii(:),jj(:)
allocate (ii(2),jj(3))
jj = 0
ii = jj ! invalid -- arrays do not conform
! jj = ii
print*,ii
end program xalloc
IVF 9.1.034 with the options
/traceback /check:all /warn:all /warn:unused
compiles and runs, giving output "0 0" modulo spacing. If the line "jj = ii" is uncommented the program terminates at that line, with an informative error message. It appears that the array bounds checking catches cases where the RHS array is smaller than the LHS array but not where the RHS array is larger. It would be nice to catch the latter. G95 exhibits the same behavior, but Mingw gfortran 4.3.0 20070329 catches both cases. It would be nice if the Intel compiler caught both cases.
I believe that in Fortran 2003, if the LHS is an allocatable array, it need not conform to the RHS, although they must have the same rank. The LHS array is allocated to be the same shape as the RHS. This feature seems convenient but a little dangerous to me.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page