Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
31 Views

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

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
Highlighted
31 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
Highlighted
New Contributor I
31 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
Highlighted
31 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
Highlighted
New Contributor I
31 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
Highlighted
31 Views

I expect this bug to be fixed in Update 2.

0 Kudos