Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Doubt w.r.t. to Fortran2003 standard

$
0
0

Dear Intel Fortran Compiler users,

I would like to know whether the following code snippet

module overwrite
  type madre
   contains
     procedure :: sum => sum_madres
     generic   :: operator(+) => sum
  end type madre

  type, extends(madre) ::  hijo
  contains
     procedure :: sum => sum_hijos_compliant
  end type hijo

contains

function sum_madres(op1,op2) result(res)
 implicit none
 class(madre), intent(in) :: op1, op2
 class(madre), pointer    :: res
 write(*,*) 'sum_madres'
end function sum_madres

function sum_hijos_compliant(op1,op2) result(res)
   implicit none
   class(hijo) , intent(in) :: op1
   class(madre), intent(in) :: op2
   class(madre), pointer    :: res
   write(*,*) 'sum_hijos'
end function

end module overwrite

program drive_ovw
  use overwrite
  implicit none

  type(madre) :: m1, m2
  type(hijo)  :: h1, h2
  class(madre), pointer :: hres

  hres => h1 + m2

end program drive_ovw

should output 'sum_hijos' or 'sum_madres'. With the Intel and GFORTRAN compilers I get 'sum_madres', while with the IBM XLF compiler I get 'sum_hijos'.

I have already reported this same query in the following forum:

https://groups.google.com/forum/#!topic/comp.lang.fortran/aFNK3FXqTUA

and one very related here:

https://gcc.gnu.org/ml/fortran/2014-10/msg00124.html

with no clear answer yet.

Thanks in advance.
Best regards,
 Alberto.


Viewing all articles
Browse latest Browse all 3270

Trending Articles