replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Compiler gives false bounds error with /check
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 

Compiler gives false bounds error with /check

 
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: Mon Feb 02, 2015 1:48 am    Post subject: Compiler gives false bounds error with /check Reply with quote

In the following program, a section of an assumed shape 2-D array is passed to a function which expects a 1-D array. The 7.10 FTN95 compiler gives a false bounds error as indicated in the listing. Viewing the run in SDBG shows the array X as having a dimension (1) at the point where the program aborted.

The program should run without error.
Code:
! Compile with /check and run
! Will give false "array subscript out of bounds"
! error in function SNRM2 below
program arraybug
implicit none
real, dimension(:,:), allocatable :: c
integer m,n,i,j
real :: x

m=3
n=4
allocate(c(m,n))
do i=1,m
   do j=1,n
      c(i,j)=100*i+j
   end do
end do
call sub(c,m)

contains
subroutine sub(c,m)
implicit none
integer :: m
real, dimension(:,:) :: c
x=snrm2(m,c(:,2))
write(*,*)x
end subroutine

function snrm2(n,x) result(ssq)
implicit none
real :: x(*),ssq,absxi
integer :: n,i

ssq=0
do i = 1, n
   absxi = abs ( x(i) )   ! <<<=== falsely gives subscript error here!
   ssq = ssq +  absxi**2
end do
return
end function snrm2

end program


[P.S., 15 June 2015: The fix described by Paul Laidler is present in FTN95-7.20]


Last edited by mecej4 on Mon Jun 15, 2015 11:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Feb 02, 2015 10:14 am    Post subject: Reply with quote

Thanks for this. I have logged it for investigation.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Thu Feb 05, 2015 8:55 am    Post subject: Reply with quote

For the time being this bug has been "fixed" by removing the array bounds check for star-sized arguments in internal functions.
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