public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36526]  New: pointer in pure function
@ 2008-06-13 12:58 aradi at bccms dot uni-bremen dot de
  2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: aradi at bccms dot uni-bremen dot de @ 2008-06-13 12:58 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-27 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
2008-06-20 10:44 ` pault at gcc dot gnu dot org
2008-06-25 23:06 ` pault at gcc dot gnu dot org
2008-08-08 22:24 ` jv244 at cam dot ac dot uk
2008-11-18 10:03 ` pault at gcc dot gnu dot org
2008-11-27 22:23 ` pault at gcc dot gnu dot org
2008-11-27 22:24 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).