elemental optr. between abstract arrays (catastrophic)

elemental optr. between abstract arrays (catastrophic)

Hello,

here's an other catastrophic compiler error report (version 14.0.1); maybe it helps to improve ifort!

The error is caused by invoking an elemental binary operator (as '==') on polymorphic arrays of abstract declared type.

module m

	    implicit none

	 

	    ! abstract parent type with elemental equality operation

	    type, abstract :: abstr_parent_type

	    contains

	        procedure(is_equal_interf), deferred :: is_equal

	        generic :: operator(==) => is_equal

	    end type

	 

	    abstract interface

	        elemental function is_equal_interf(this, other)

	            import abstr_parent_type

	            class(abstr_parent_type), intent(in) :: this, other

	            logical :: is_equal_interf

	        end function

	    end interface

	 

	    ! extended type overrides abstract equality operation

	    type, extends(abstr_parent_type) :: child_type

	        integer :: field = 0

	    contains

	        procedure :: is_equal => child_type_is_equal

	    end type

	 

	contains

	    elemental function child_type_is_equal(this, other)

	        class(child_type), intent(in) :: this

	        class(abstr_parent_type), intent(in) ::  other

	        logical :: child_type_is_equal

	 

	        ! any comparision code

	        child_type_is_equal = .true.

	    end function

	end module

	 

	program t

	    use m

	    implicit none

	 

	    ! must be array(!) of abstract(!) parent in order to crash

	    class(abstr_parent_type), allocatable, dimension(:) :: arr1, arr2

	 

	    ! run elementwise comparisions on child_types

	 

	    allocate(child_type :: arr1(1), arr2(1))

	 

	    ! variant 1: catastrophic error

	    if (all(arr1 == arr2)) then                          ! CRASH

	        print *, 'arrays are equal'

	    end if

	 

	    ! variant 2: no error (legal?)

	    if (all(arr1%is_equal(arr2))) then

	        print *, 'arrays are equal'                      ! works

	    end if

	 

	end program

	

COMPILE LINE:
ifort elementwise_type_bound.f90

OUTPUT:
catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
compilation aborted for elementwise_type_bound.f90 (code 1)

WORKAROUND QUESTION:
Is variant 2 (with the elemental type bound function invocation directly on the array) a standard conforming F2003 alternative?

Thanks,
Ferdinand

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

Thanks - I will send this off to the developers. There's nothing wrong with calling the function directly - indeed, the use of the operator ought to translate to a call to the function.

Retired 12/31/2016

Quote:

Steve Lionel (Intel) wrote:

There's nothing wrong with calling the function directly - indeed, the use of the operator ought to translate to a call to the function.

It's just that I never called a type bound function from an arrayvariable before, e.g. 'arr%func()' instead of 'array(index)%func()' and I am glad to hear that this is legal syntax. Thank you!

With an elemental function, the syntax you chose passes an array which is fine.

Issue ID is DPD200249693.

Retired 12/31/2016

While writing some code with that nice 'elemental function on array invokation' syntax I run into a probably related issue (catastrophic compiler abort on type bound elemental generic, when called from array) which I managed to reduce to the following program:

module m
    implicit none
 
    ! type bound elemental generic
    type :: derived_type
    contains
        ! generic interface for type bound elemental (pass or nopass)
        procedure, nopass :: do_specific
        generic :: do_generic => do_specific
    end type
 
contains
    elemental subroutine do_specific()
    end subroutine
end module
 
program p
    use m
    implicit none
 
    ! must be array(!) of derived types in order to crash
    type(derived_type), dimension(1) :: my_derived
 
    call my_derived%do_specific()         ! works
    call my_derived%do_generic()          ! CRASH
end program

In the hope posting those issues here is helpful and with best regards,
Ferdinand

Yes, your posting these is very helpful! Thanks.

Retired 12/31/2016

Leave a Comment

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