Hi, 

 I discovered a problem with gfortran 4.3.1 when compiling code with pure
function with pointer argument. Inside the pure function, the argument is
passed further to an other function. This seems to work, as long this other
function is an intrinsic function, but seems to fail for user defined pure
functions. The effect is demonstrated by the code below.

  Best regards,

    Bálint

--------------------------------------------------------
module TestPure
  implicit none

  type T1
    character(10) :: str
  end type T1

contains

  pure function getT1Len(self) result(t1len)
    type(T1), pointer :: self
    integer :: t1len

    t1len = getStrLen(self%str)
    !t1len = len_trim(self%str)   ! <- this would work

  end function getT1Len


  pure function getStrLen(str) result(length)
    character(*), intent(in) :: str
    integer :: length

    length = len_trim(str)

  end function getStrLen

end module TestPure


program Test
  use TestPure
  implicit none

  type(T1), pointer :: pT1

  allocate(pT1)
  pT1%str = "test"
  write (*,*) getT1Len(pT1)
  deallocate(pT1)

end program Test
------------------------------------------------------


-- 
           Summary: pointer in pure function
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aradi at bccms dot uni-bremen dot de
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526

Reply via email to