Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Internal compiler error - character(:) pointer in function declaration

$
0
0

The program below gives an internal compiler error for ifort (IFORT) 14.0.3 20140422 under Linux.  It is the character(:) in front of function getS that triggers the error.  Moving character(:) to the pointer statement four lines below makes everything work ok.

MODULE testModule

  TYPE :: FOO

     CHARACTER(LEN=:), ALLOCATABLE :: s 

   CONTAINS

     PROCEDURE, PASS(this) :: getS

     PROCEDURE, PASS(this) :: setS

  END TYPE FOO

CONTAINS

 

  PURE SUBROUTINE setS( this, s )

    !

    CLASS(foo),   INTENT(inout) :: this

    CHARACTER(*), INTENT(in)    :: s

    IF( .NOT. ALLOCATED( this % s ) ) THEN

       ALLOCATE( this % s, SOURCE=s )

    ELSE IF ( LEN(this % s) /= LEN(s) ) THEN

       DEALLOCATE( this % s )

       ALLOCATE( this % s, SOURCE=s )

    ELSE

       this % s = s

    END IF

  END SUBROUTINE setS

  CHARACTER(:) FUNCTION getS( this ) RESULT( p )

    !

    CLASS(foo), INTENT(in), TARGET :: this

    !

    POINTER :: p

    p => this % s

  END FUNCTION getS

END MODULE testModule



PROGRAM testProgram

  USE testModule

  TYPE(foo),    TARGET  :: someFoo

  CHARACTER(:), POINTER :: stringInType

  CALL someFoo%setS( "The quick brown fox jumps over the lazy dog." )

  stringInType => someFoo%getS()

  PRINT '(A)', stringInType

END PROGRAM testProgram


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>