fortran - SELECT TYPE with unlimited polymorphic pointer to CHARACTER(*) variable -


following example uses fortran 2003 features defining unlimited polymorphic pointers , performing actions based on variable type following select type construct. subroutine handlep prints value of argument in dependence of it's type.

program example     implicit none     type name         character(22) :: n     end type      character(len=7) :: mystring     mystring = 'initial'      call handlep(mystring)     call handlep('initial')     call handlep(name('initial'))      contains          subroutine handlep(p)             class(*), intent(in) :: p              select type(p)             type (character(len=*))                 write(*,*) len(p), ': ', p             class (name)                 write(*,*) len(p%n), ': ', p%n             class default                 write(*,*) 'unknown type'             end select         end subroutine  end program example 

compiling gfortran version 4.8 gives following output:

       7 : initial        0 :       22 : initial 

so, call handlep(mystring) works expected, call handlep('initial') printing fails. calling type(name) argument works.

is behaviour call handlep('initial') gfortran bug or doing wrong? if bug, prevent it?

i want let know issue fixed under gfortran 4.9.3-1 comes current mingw installation.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -