Silverfrost Forums

Welcome to our forums

FTN95 bug: array valued functions in expressions

4 Jun 2015 1:45 (Edited: 15 Jun 2015 9:58) #16420

FTN95 7.1 has problems processing expressions that contain array constructors and functions that return arrays. Some of these problems surfaced in a recent thread ( https://forums.silverfrost.com/Forum/Topic/2741 ), and here is a simple reproducer.

program getdiag 
implicit none
real matrix(2,2),d4(4) 
!
matrix=reshape((/ 2.,4.,5.,3. /),(/2,2/)) 
d4 = (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here
print*,d4

contains
   function diagf(A)
      real :: A(2,2),diagf(2)
      diagf = (/ A(1,1), A(2,2) /)
      return
   end function
end program

The compiler says

0006) d4 = (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here
*** Non-conformant array shapes in first rank of an array expression (4 and 3)

which suggests that it does not recognize that diagf() is of size 2, not 1.

If the array constructor is used in an I/O list, compilation goes through, but the resulting program attempts to read from address zero.

program getdiag 
implicit none
real matrix(2,2)
!
matrix=reshape((/ 2.,4.,5.,3. /),(/2,2/)) 
print *, (/ 1.0, diagf(matrix), 4.0 /) ! FTN95 bug here

contains
   function diagf(A)
      real :: A(2,2),diagf(2)
      diagf = (/ A(1,1), A(2,2) /)
      return
   end function
end program

[P.S. 6/15/2015]Same bugs also present in FTN95-7.20.

5 Jun 2015 8:22 #16426

Thanks for the information. I have logged this for investigation.

6 Jul 2020 9:33 #25913

This bug has now been fixed for the next release of FTN95.

Please login to reply.