Silverfrost Forums

Welcome to our forums

Syntax error that escapes detection

15 Oct 2022 1:08 #29447

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!

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.

15 Oct 2022 5:57 #29448

mecej4

Many thanks for the feedback. I have made a note that this needs fixing.

15 Oct 2022 7:23 #29449

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

Please login to reply.