issue with type-bound operator in polymorphic

issue with type-bound operator in polymorphic


on compiling the following code, I ran into a problem using the latest ifort 13.1.3:

module m
    implicit none
    ! derived-type with type-bound operator
    type :: element_type
        logical :: non_empty
        procedure :: multiply
        generic :: operator(*) => multiply ! (*)
        ! comment out 'generic,...' and it works
    end type
    ! derived-type with generic procedure
    type :: super_type
        logical :: non_empty
        procedure :: do_specific
        generic :: do_something => do_specific
    end type 
    type, extends(super_type) :: child_type
        procedure :: do_specific_child
    end type 
    ! mixed operation between 'element_type' * 'child_type'
    function multiply(this, child) result(res)
        class(element_type), intent(in) :: this
        type(child_type), intent(in) :: child  ! (**)
        integer :: res
        res = 1
        ! (**): replace 'child_type' with 'super_type'
        !        (or any other type), and it works
    end function
    function do_specific(this) result(value)
        class(super_type), intent(in) :: this
        integer :: value
        value = 1
    end function
    function do_specific_child(this) result(value)
        class(child_type), intent(in) :: this
        integer :: value
        value = 1
    end function
end module
program p
    use m
    implicit none
    type(super_type) :: super
    type(child_type) :: child
    print *, super%do_something() ! ok
    print *, child%do_something() ! error #8485
    ! error #8485: There is no matching specific function for this 
    ! type bound generic function reference.   [DO_SOMETHING]
end program

  1. A derived-type 'super_type' which is extended by 'child_type' is equipped with some generic type-bound interface procedure.
  2. An other derived-type 'element' defines a mixed type-bound 'multiply' operation ('*') between itself and the extended 'child_type'
  3. Now it seems to be impossible to call any generic type-bound procedures of the 'child-type' (see code).

Maybe it is related to Because of that other problem, a workaround with 'non'-type-bound operators doesn't seem to be a solution for now. But how is it possible to define operators for my classes, then?

I would be happy if someone can help me with this issue. Is it legal code? Is there a fix to appear? Or do you know a workaround?

Thank you, with best regards


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


This is a problem we have fixed for a release later this year.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today