sigment
Joined: 17 Dec 2007 Posts: 10
|
Posted: Sat Jun 28, 2008 4:48 pm Post subject: Runtime error with array-valued function |
|
|
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?
Code: | 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 |
|
|