This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with calling abstract class procedure from pointer


Hello,
I seem to hit a bug with gfortran when I have a pointer to an abstract class,
and try to call type-bound (deferred) procedure in that abstract class. Here's
the code I have for example:
--------------------
module SolverModule
  type, public :: SolverType
    class ( EquationTemplate ), pointer :: Equation => null ( )
  contains
    procedure, public, pass :: Solve
  end type SolverType

  type, abstract :: EquationTemplate
  contains
    procedure ( EvaluateInterface ), public, deferred, pass :: Evaluate
  end type EquationTemplate

  abstract interface
    subroutine EvaluateInterface ( ET, X )
      import EquationTemplate
      class ( EquationTemplate ), intent ( in ) :: ET
      real, intent ( in ) :: X
    end subroutine EvaluateInterface
  end interface

contains

  subroutine Solve ( S, ET )
    class ( SolverType ), intent ( inout ) :: S
    class ( EquationTemplate ), intent ( in ), target :: ET
    real :: X

    S % Equation => ET
    !-- This produce compile error
    call S % Equation % Evaluate ( X )
    !-- This is OK
    call ET % Evaluate ( X )
  end subroutine Solve
end module SolverModule
-----------------------

Compiling this with the latest gcc-4.8 (nightly snapshot), I got:
$ /usr/local/gcc/4.8/bin/gfortran -c Solver_Module.f90
Solver_Module.f90:30.32:

    call S % Equation % Evaluate ( X )
                                1
Error: 'evaluate' at (1) is not a member of the 'equationtemplate' structure

If I put EvaluationTemplate definition before the SolverType, then this would
compile without error. PGI and Cray compiler seem to compile this without
error. So this seems like a bug in gfortran ? Please let me know if I can
provide futher info.

Best,
RDB


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]