Silverfrost Forums

Welcome to our forums

Runtime error with array-valued function

28 Jun 2008 3:48 #3427

The program below, using an array-valued function, gives runtime errors with FTN95 5.20.1 and 5.21.0 no matter what options I use but works with my other compilers and I believe it is well-formed. With a simple ftn95 <file> /LINK build it gives a stack overflow and with a /FULL_DEBUG /CHECKMATE build I get:

Access Violation The instruction at address 1000429a attempted to write to location 20202020

100041f1 __CCOPY_U [+00a9] ARRAY_OF - in file a.f90 at line 5 [+015c] TEST - in file a.f90 at line 19 [+004e]

Making the return value a fixed length character or a scalar REAL eliminates the errors. Any ideas?

FUNCTION ARRAY_OF( Arg )
  IMPLICIT NONE
  CHARACTER(*), INTENT(IN) :: Arg
  CHARACTER( LEN( Arg ) ) :: ARRAY_OF( 1 )
  ARRAY_OF( 1 ) = Arg
END FUNCTION ARRAY_OF


PROGRAM TEST
  CHARACTER(4) :: S = 'ABCD', SA(1)

  INTERFACE
  FUNCTION ARRAY_OF( Arg )
    CHARACTER(*), INTENT(IN) :: Arg
    CHARACTER( LEN( Arg ) ) :: ARRAY_OF( 1 )
  END FUNCTION ARRAY_OF
  END INTERFACE

  SA = ARRAY_OF( S )
  PRINT *, SA(1)
END PROGRAM
30 Jun 2008 11:36 #3429

This looks like a bug in FTN95. We will investigate and report back as soon as we can.

Please login to reply.