interface operator for extended derived-type

interface operator for extended derived-type

Hello,

in the example shown below I try to define a (non-type-bound*) operator for an extended derived-type "child". However, declaring the interface for the operator causes the Intel compiler to give me some errors which I do not understand. In some cases, the compiler even experiences a segmentation violation.

*) I didn't use type-bound operators, because I want to define operators between many different child - types, all of them extending one common 'super' - type, which at some point requires arguments (child - types) to appear in the type-bound operator function before they are declared.

module m
 
    ! superclass with type-bound generic
    type :: super
    contains
        procedure :: proc_specific
        generic :: proc_generic => proc_specific
    end type
 
    ! child inherits type-bound generic
    type, extends(super) :: child
    end type
 
    ! an arbitrary operator on the child, causes errors (see below)
    ! note: no errors caused if operator is declared for 'super' instead
    interface operator(.optr.)
        function multiply(arg1,arg2)
            import child
            implicit none
            type(child), intent(in) :: arg1, arg2
            type(child) :: multiply
        end function
    end interface
 
contains
 
    logical function proc_specific(this)
        implicit none
        class(super) :: this
    end function
end module
 
program p
    use m
    implicit none
    type(child) :: myChild
 
    print *, myChild%proc_specific()
    ! works fine
 
    print *, myChild%proc_generic()
    ! error #8485: There is no matching specific function for this
    !              type bound generic function reference.
    ! error #8497: Illegal use of a procedure name in an expression, 
    !              possibly a function call missing parenthesis.
 
    ! call myChild%proc_generic()
    ! note: the use of a subroutine (proc_specific) instead of a function
    !       (deleting the return type) leads to a compiler segmentation
    !       violation as long as the operator is declared for 'child'
end program

It seems to me that a generic operator interface for an extended derived-type somehow destroys all of it's type-bound inherited generic interfaces. Or am I finally making a mistake here? Is there an other way to define an operator for the 'child' (without dynamic 'select case')?

Any suggestions are appreciated!

Best regards, Ferdinand

4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Steve Lionel (Intel)

Thanks - I can reproduce both problems. Let me look into it a bit more and I'll get back to you. I don't think you're doing anything wrong.

Steve
Portrait de Steve Lionel (Intel)

Escalated as issue DPD200241686. Thanks for the nice example.

Steve
Portrait de Steve Lionel (Intel)

I expect this problem to be fixed in a release later this year.

Steve

Connectez-vous pour laisser un commentaire.