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 

Syntax error that escapes detection

 
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: 1885

PostPosted: Sat Oct 15, 2022 2:08 am    Post subject: Syntax error that escapes detection Reply with quote

The following program attempts to use an assumed-size array argument as if it were an assumed-shape array. A compiler should be able to catch the error at compile time and refuse to produce an object file or an EXE. FTN95 happily compiles this code!

Code:
program assumed
implicit none
integer, parameter :: N = 100
real :: X(N)
!
call random_number(X)
print *,sadd(X)

contains
   real function sadd(X)
      implicit none
      real X(*)              ! note assumed size
      sadd = sum(X(:)) ! bug here, X is not assumed shape, size(X) is unknown
      return
   end function sadd
end program assumed


In a longer program in which this error existed, the program crashed with an access violation. The /check and /checkmate options did not enable the bug to be detected or located.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Oct 15, 2022 6:57 am    Post subject: Reply with quote

mecej4

Many thanks for the feedback. I have made a note that this needs fixing.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Oct 15, 2022 8:23 am    Post subject: Reply with quote

This has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
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