------- Comment #1 from janus at gcc dot gnu dot org  2010-03-04 16:04 -------
(In reply to comment #0)
> Apparently this only happens for type-bound character-valued functions (but 
> not
> for subroutines or e.g. integer-valued functions).

Actually that is wrong. It does work with subroutines, but it fails with all
sorts of functions, also integer-valued ones, and with NOPASS:

module module_myobj

  implicit none

  type :: myobj
  contains
    procedure, nopass :: myfunc
  end type

contains

  integer function myfunc(status)
    integer, optional :: status
    if (present(status)) then
      write (*,*) 'myfunc: status is present.'
    else
      write (*,*) 'myfunc: status is not present.'
    end if
    myfunc = 1
  end function

end module


program test_optional

  use :: module_myobj
  implicit none

  integer     :: res,status
  type(myobj) :: myinstance

  res = myfunc()                   ! OK
  res = myfunc(status)             ! OK
  res = myinstance%myfunc()        ! FAILED
  res = myinstance%myfunc(status)  ! OK

end program


For checking if it works, one should not only look at the output of the
program, since this could be correct by chance. Instead, one should look at the
dump, to see if a zero is passed for the missing optional arg.


-- 


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

Reply via email to