Polymorphic types - internal compiler error

Polymorphic types - internal compiler error

Hello,
I have been playing around with the following example:

PROGRAM test
    IMPLICIT NONE
    INTEGER, PARAMETER :: max_str_len = 32
    CHARACTER(LEN=max_str_len) :: str
    INTEGER :: i
    str = '7'
    CALL Load(str, i)
    WRITE(*, *) "i = ", i
CONTAINS
SUBROUTINE Load(str, val)
    CHARACTER(LEN = max_str_len), INTENT(IN) :: str
    CLASS(*), INTENT(INOUT) :: val
    SELECT TYPE(val)
        TYPE IS(INTEGER)
            READ(str, *) val
        TYPE IS(REAL)
            READ(str, *) val
        TYPE IS(CHARACTER(*))
            READ(str, *) val
    END SELECT
END SUBROUTINE
END PROGRAM

When I try to compile it with
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1.5.339 Build 20120612
using -O0, the code compiles, nevertheless it produces a segmentation fault. Using -On for n>=1, ifort meets
its demise by stating that "catastrophic error: **Internal compiler error".

However, ifort "Version 13.0.1.117 Build 20121010" seems to produce the expected result "i = 7".

Interestingly, a slighly modified version of the subroutine works even with ifort v 12, namely:

SUBROUTINE Load(str, val)
    CHARACTER(LEN = max_str_len), INTENT(IN) :: str
    CLASS(*), INTENT(INOUT) :: val
    INTEGER :: i
    REAL :: z
    CHARACTER(LEN=max_str_len) :: str_temp
    SELECT TYPE(val)
        TYPE IS(INTEGER)
            READ(str, *) i
            val = i
        TYPE IS(REAL)
            READ(str, *) z
            val = z
        TYPE IS(CHARACTER(*))
            READ(str, *) str_temp
            val = str_temp
    END SELECT
END SUBROUTINE

Therefore it looks like that the "catastrophic error" is caused by presence of a CLASS(*) variable
in the READ statement. However, within the SELECT TYPE section, this should be a valid
construct, shouldn't it?

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

"internal compiler error" or "catastrophic error" is a bug in the compiler, and can appear for both valid and invalid source files. As you discovered, we fixed the bug. Yes, the construct is valid.

Steve - Intel Developer Support

Leave a Comment

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