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

catastrophic ICE when allocating class(*) components with character sources

joseph_battelle
Beginner
877 Views
See below for ALLOCATE statements that ICE when trying to allocate unlimited polymorphic components with a character source. Seems like the allocatable must be a component of a derived type and the source must be a variable to trigger the ICE. Notice the automatic variable allocation is fine. Also note integer sources work fine as well. In my code I am currently working around this by allocating in one step, and assigning in a second block that does type selection on the polymorphic component.

[fortran]module m8
    type pair
        integer :: key
        class(*), allocatable :: val
    end type pair
contains

    subroutine foo(c)
    character(len=*) :: c
        type(pair) :: p
        class(*), allocatable :: val
        character(len=6), parameter :: s = "hi joe" 
        character(len=:), allocatable :: tmp
        integer :: i = 5
        
        tmp = "hi joe"
        allocate (val, source = c) !OK; allocatable is not a component
        allocate (p%val, source = "hi joe") !ok; source is a literal
        allocate (p%val, source = s) !OK; source is a parameter
        allocate (p%val, source = i) !OK; source is an integer
        allocate (p%val, source = tmp) !0_12032
            !: catastrophic error: **Internal compiler error: internal abort**
        allocate (p%val, source = c) !0_12032
            !: catastrophic error: **Internal compiler error: internal abort**

    end subroutine foo
end module m8[/fortran]

0 Kudos
1 Solution
Steven_L_Intel1
Employee
877 Views
Joseph,

Thanks - the issues with ALLOCATE are escalated as DPD200157386. Not that your program uses this, but I will comment that we do not currently support SOURCE= where the source is polymorphic - just in case you decided to try that.

The move_alloc issue is known and is being worked on. Issue ID is DPD200151581.

View solution in original post

0 Kudos
6 Replies
joseph_battelle
Beginner
877 Views
Also if you noticed the automatic val worked and you think a clever way to defeat the ICE is to move_alloc from the temporary to your component, you are mistaken :) Another ICE if you append this to the end of FOO above:

[fortran]        call move_alloc (val,p%val) !catastrophic error: **Internal compiler error: internal abort** 
!-------^[/fortran]

0 Kudos
Steven_L_Intel1
Employee
877 Views
Thanks - we'll get this fixed.
0 Kudos
joseph_battelle
Beginner
877 Views
Thanks Steve. Also while some of the allocations above compile OK the runtime behavior is suspect--they all crash on me. For those that are curious I've switched to code below to initialize unlimited polys with characters and it seems to be working ok. I'll switch it back when SOURCE= is debugged.
[fortran]        allocate (character(len=len(c)):: p%val)
        select type (z => p%val)
        type is (character(len=*))
            z = c
        end select[/fortran]
0 Kudos
Steven_L_Intel1
Employee
878 Views
Joseph,

Thanks - the issues with ALLOCATE are escalated as DPD200157386. Not that your program uses this, but I will comment that we do not currently support SOURCE= where the source is polymorphic - just in case you decided to try that.

The move_alloc issue is known and is being worked on. Issue ID is DPD200151581.
0 Kudos
joseph_battelle
Beginner
877 Views
Already tried polymorphic sources and your compiler gives a nice "not implemented yet" in that case instead of an ICE. When I have an unlimited poly I want to use with the current compiler I wrap it in a select type block to give the allocate statement something it can use. Unfortunately this adds unnecessary coupling in some of my generics so I'm looking forward to when all these source= issues are addressed and I can clean up my code to reduce the coupling from the type selection. For now I'm happy that most of what I want to do can be done with a few workarounds.
0 Kudos
Steven_L_Intel1
Employee
877 Views
This has been fixed in Composer XE 2011 Update 6. Polymorphic source for ALLOCATE is also now supported.
0 Kudos
Reply