Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

find a reason of catastrophic error when Fortran compiling...

Li_L_
New Contributor I
618 Views

when i call a function which result a derived-type with a final procedure

then the compiling collapsed with just a reminder of "catastrophic error"

may this post help someones save some time

 

0 Kudos
5 Replies
Steven_L_Intel1
Employee
618 Views

It's a compiler bug. Please provide us with a source that demonstrates the problem and tell us the exact compiler version and compiler options you are using.

0 Kudos
Li_L_
New Contributor I
618 Views

Steve Lionel (Intel) wrote:

It's a compiler bug. Please provide us with a source that demonstrates the problem and tell us the exact compiler version and compiler options you are using.

!call a function which result a derived-type with a final procedure
!the compiling would collapsed with just 'catastrophic error'
module abs
    type:: sa
        real(8):: a
    end type sa
    
    type::  sb
        real(8),allocatable:: b(:)
    contains
        final::     cancel
    end type sb
contains
    subroutine cancel(this)
    type(sb)::  this
    end subroutine
end module
    
module classpointer
use abs
   
    type:: proptr
        procedure(fca),pointer,nopass:: ptr
    end type

    type:: pointercontainer
        real(8),pointer,dimension(:)::  ptr
        procedure(fca),pointer::        fp
        type(proptr),dimension(2)::     fpset
    contains
        procedure::                     init
    end type pointercontainer
    
    abstract interface
        function fca(this,a)
        import
        class(pointercontainer)::   this
        type(sa)::                  a
        type(sb)::                  fca
        end function
    end interface

contains

    subroutine init(this)
    class(pointercontainer):: this
        this%fpset(1) %ptr => fc
        this%fpset(2) %ptr => fc
        this%fp => this %fpset(2) %ptr
    end subroutine
    
    function fc(this,a) result(dd)
    class(pointercontainer)::   this
    type(sa)::                  a
    type(sb)::                  dd
        allocate(dd%b(2))
        dd %b= 2.d0
        print*, 'smile'
    end function
    
end module classpointer

program testMemberFunction
use classpointer
implicit none
type(pointercontainer)::    p
type(sa)::                  a

    call p%init
    print*, p%fp(a)

end program testMemberFunction

 

don't know how to use this forum......

the key is the line "final::  cancel" in moduel abs

0 Kudos
Steven_L_Intel1
Employee
618 Views

Thanks, that was fine. I can reproduce the problem and will send it on to the developers. Issue ID is DPD200414609.

However, the program is incorrect - a current version of the compiler complains:

U697080.f90(70): error #5514: A derived type I/O list item that contains a pointer or an allocatable component requires a user-defined derived-type input/output procedure.
    print*, p%fp(a)
----^

The result of fp(a) is type sb that contains an allocatable component. The language therefore requires that type sb have a user-defined derived type I/O procedure.

This is unrelated to the internal compiler error, but I wanted to point it out anyway.

0 Kudos
Li_L_
New Contributor I
618 Views

Steve Lionel (Intel) wrote:

Thanks, that was fine. I can reproduce the problem and will send it on to the developers. Issue ID is DPD200414609.

However, the program is incorrect - a current version of the compiler complains:

U697080.f90(70): error #5514: A derived type I/O list item that contains a pointer or an allocatable component requires a user-defined derived-type input/output procedure.
    print*, p%fp(a)
----^

The result of fp(a) is type sb that contains an allocatable component. The language therefore requires that type sb have a user-defined derived type I/O procedure.

This is unrelated to the internal compiler error, but I wanted to point it out anyway.

thanks, my compiler fails to capture this error!

this forum is awesome and i learned much from it. it's my pleasure to help the others

0 Kudos
Steven_L_Intel1
Employee
618 Views

I expect this bug to be fixed in Update 2.

0 Kudos
Reply