replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - BUG in FTN95 V5.50
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BUG in FTN95 V5.50

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1899

PostPosted: Fri Apr 09, 2010 6:54 pm    Post subject: BUG in FTN95 V5.50 Reply with quote

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!
Back to top
View user's profile Send private message
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Mon Apr 12, 2010 9:59 am    Post subject: Reply with quote

It is my understanding that FORTRAN 95 doesn't allow ALLOCATABLE components of user defined types - you have to simulate it by using the POINTER attribute for components that you want to ALLOCATE. In which case, the real bug is that FTN95 doesn't spot the illegal syntax?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group