issue with type-bound operator in polymorphic

issue with type-bound operator in polymorphic

Hello,

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
    contains
        procedure :: multiply
        generic :: operator(*) => multiply ! (*)
        
        ! comment out 'generic,...' and it works
    end type
    ! derived-type with generic procedure
    type :: super_type
        logical :: non_empty
    contains
        procedure :: do_specific
        generic :: do_something => do_specific
    end type 
    type, extends(super_type) :: child_type
    contains
        procedure :: do_specific_child
    end type 
contains
    ! 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 http://software.intel.com/en-us/forums/topic/374846. 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

Ferdinand

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

Ferdinand,

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

Steve - Intel Developer Support

Leave a Comment

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