mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Fri Apr 09, 2010 6:54 pm Post subject: BUG in FTN95 V5.50 |
|
|
FTN95 does not allow allocatable dummy arguments (TR15581 extension to F95). That is as it stands, and the compiler correctly prints a message when given code that uses this extension.
However, if an allocatable array is a member of a structure, it can be inadvertently sneaked in as an argument by passing the structure as the argument, as in this example:
Code: | program buggy
type :: squirrel
integer, dimension(:), allocatable :: iv
end type squirrel
type(squirrel) :: sivec
integer :: i,n
write(*,*)allocated(sivec%iv) ! should print FALSE or F
n=4
call allocivec(sivec,n)
write(*,*)allocated(sivec%iv) ! should print TRUE or T
if(allocated(sivec%iv))deallocate(sivec%iv)
contains
subroutine allocivec(sivec,n)
type(squirrel) :: sivec
integer :: n
allocate(sivec%iv(n))
return
end subroutine allocivec
end program buggy
|
FTN95 happily compiles and the program prints T for both write statements. The correct results are T \n F.
If the "allocate" statement in the subroutine is commented out, the correct printout would be F \n F, but FTN95 says T \n T still, but seg-faults on the DEALLOCATE statement
This is a contrived example, to be sure. The bug occurred in a larger program of around 31,000 lines, and was quite hard to locate! |
|