Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

Bug in Intel 2019 with private attribute

lina
Beginner
170 Views

module Timer_c
  implicit none
  private

  type, public :: timer_t
    private
    real :: savedTime
  contains
    private
    procedure :: StartTimer  => StartTimerSub
    procedure :: ElapsedTime => ElapsedTimeFun
  end type timer_t

contains

  subroutine StartTimerSub(this)
    class(timer_t) :: this
    this%savedTime = 0.0
  end subroutine StartTimerSub

  function ElapsedTimeFun(this) result(retVal)
    class(timer_t) :: this
    real :: retVal
    retVal = 1.0 - this%savedTime
  end function ElapsedTimeFun

end module Timer_c

program TestTimer
  use Timer_c
  implicit none
  type(timer_t) :: t

  call t%StartTimer()
  write(*, *) t%ElapsedTime()

end program TestTimer
 

Both StartTimer and ElapsedTime are declared as private, but the compiler give only one error that ElapsedTime is private, StartTimer is still accessible in main program. That means functions are handled correctly, not subroutines. However, in gfortran compilers, both errors are detected. I think this is a bug.

0 Kudos
0 Replies
Reply